aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 18:36:19 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 18:36:19 -0500
commit36a453d2c1237b49f594b23433858a0146dbf31e (patch)
tree2aa337a8bae309933e350a7120325b00b0b259ac /modules
parent63c60fefd4d03ba22d3a36f793fe466daae43c7e (diff)
downloaddotemacs-36a453d2c1237b49f594b23433858a0146dbf31e.tar.gz
dotemacs-36a453d2c1237b49f594b23433858a0146dbf31e.zip
refactor(load-graph): make hidden module dependencies explicit
Phase 2 of the load-graph project. I fixed the seven hidden dependencies the classification surfaced, so each module declares what it uses instead of relying on init order. - system-defaults now requires host-environment and user-constants at runtime. They were eval-when-compile only, but env-bsd-p and user-home-dir are read at load, so the compiled module couldn't load standalone. - custom-buffer-file, dev-fkeys, calendar-sync, and video-audio-recording require keybindings and drop their (when (boundp 'cj/custom-keymap) ...) shims. The shim silently dropped the C-; binding when the module loaded before keybindings. The explicit require makes the dependency real. - flycheck-config and mail-config require keybindings for their cj/custom-keymap bindings (a use-package :map and a direct keymap-set). - Removed a dead eval-when-compile (defvar cj/custom-keymap) in transcription-config; nothing there used the variable. No init.el load-order change. keybindings and the foundation modules already load before these, so the requires are no-ops at startup and only fix standalone and test loading. I verified each fix with a fresh emacs --batch (require 'X), then swept all modules standalone: every one loads or fails only with a clear missing-package message. Full make test, make validate-modules, and an init smoke all pass. Module headers and the inventory's hidden-dependency section are updated to mark the seven resolved.
Diffstat (limited to 'modules')
-rw-r--r--modules/calendar-sync.el30
-rw-r--r--modules/custom-buffer-file.el12
-rw-r--r--modules/dev-fkeys.el14
-rw-r--r--modules/flycheck-config.el7
-rw-r--r--modules/mail-config.el7
-rw-r--r--modules/system-defaults.el21
-rw-r--r--modules/transcription-config.el3
-rw-r--r--modules/video-audio-recording.el11
8 files changed, 41 insertions, 64 deletions
diff --git a/modules/calendar-sync.el b/modules/calendar-sync.el
index 4d1ea219..21ef8727 100644
--- a/modules/calendar-sync.el
+++ b/modules/calendar-sync.el
@@ -13,11 +13,8 @@
;; Top-level side effects: defines a calendar keymap and conditionally registers
;; it under cj/custom-keymap; timer and network fetches guarded by
;; config/noninteractive checks.
-;; Runtime requires: cl-lib, subr-x, system-lib, cj-org-text-lib. keybindings is
-;; needed for the C-; g binding but only reached through a boundp guard, so the
-;; binding silently drops standalone. Phase 2 fix.
-;; Direct test load: conditional (C-; g registration skipped without keybindings;
-;; private config optional).
+;; Runtime requires: cl-lib, subr-x, system-lib, cj-org-text-lib, keybindings.
+;; Direct test load: yes (private config optional; degrades cleanly when absent).
;;
;; Simple, reliable one-way sync from multiple calendars to Org mode.
;; Downloads .ics files from calendar URLs (Google, Proton, etc.) and
@@ -87,6 +84,7 @@
(require 'subr-x)
(require 'system-lib) ;; provides cj/auth-source-secret-value (leaf; no ai-config dep)
(require 'cj-org-text-lib)
+(require 'keybindings) ;; provides cj/custom-keymap
(defun calendar-sync--log-silently (format-string &rest args)
"Log FORMAT-STRING with ARGS without requiring the full config."
@@ -1705,18 +1703,16 @@ Syncs all calendars immediately, then every `calendar-sync-interval-minutes'."
"S" #'calendar-sync-start
"x" #'calendar-sync-stop)
-;; Only set up keybindings if cj/custom-keymap exists (not in test environment)
-(when (boundp 'cj/custom-keymap)
- (keymap-set cj/custom-keymap "g" cj/calendar-map)
-
- (with-eval-after-load 'which-key
- (which-key-add-key-based-replacements
- "C-; g" "calendar sync menu"
- "C-; g s" "sync now"
- "C-; g i" "sync status"
- "C-; g t" "toggle auto-sync"
- "C-; g S" "start auto-sync"
- "C-; g x" "stop auto-sync")))
+(keymap-set cj/custom-keymap "g" cj/calendar-map)
+
+(with-eval-after-load 'which-key
+ (which-key-add-key-based-replacements
+ "C-; g" "calendar sync menu"
+ "C-; g s" "sync now"
+ "C-; g i" "sync status"
+ "C-; g t" "toggle auto-sync"
+ "C-; g S" "start auto-sync"
+ "C-; g x" "stop auto-sync"))
;;; Initialization
diff --git a/modules/custom-buffer-file.el b/modules/custom-buffer-file.el
index 67191244..d24c66b9 100644
--- a/modules/custom-buffer-file.el
+++ b/modules/custom-buffer-file.el
@@ -9,10 +9,8 @@
;; by init order; a deferral candidate for Phase 3/4.
;; Top-level side effects: defines cj/copy-buffer-content-map and
;; cj/buffer-and-file-map; conditionally registers the latter under C-; b.
-;; Runtime requires: external-open, mm-decode, system-lib. keybindings is needed
-;; for the C-; b registration but is declared only via eval-when-compile and
-;; guarded by `boundp', so the binding silently drops standalone. Phase 2 fix.
-;; Direct test load: conditional (C-; b registration skipped without keybindings).
+;; Runtime requires: keybindings, external-open, mm-decode, system-lib.
+;; Direct test load: yes (requires keybindings explicitly).
;;
;; This module provides custom buffer and file operations including PostScript
;; printing capabilities.
@@ -42,8 +40,7 @@
;;
;;; Code:
-;; cj/custom-keymap defined in keybindings.el
-(eval-when-compile (defvar cj/custom-keymap))
+(require 'keybindings) ;; provides cj/custom-keymap
(eval-when-compile (require 'ps-print)) ;; for ps-print variables
(declare-function ps-print-buffer-with-faces "ps-print")
(declare-function ps-print-region-with-faces "ps-print")
@@ -541,8 +538,7 @@ Signals an error if:
"<right>" #'cj/window-resize-sticky
"<up>" #'cj/window-resize-sticky
"<down>" #'cj/window-resize-sticky)
-(when (boundp 'cj/custom-keymap)
- (keymap-set cj/custom-keymap "b" cj/buffer-and-file-map))
+(keymap-set cj/custom-keymap "b" cj/buffer-and-file-map)
(with-eval-after-load 'which-key
(which-key-add-key-based-replacements
diff --git a/modules/dev-fkeys.el b/modules/dev-fkeys.el
index 02e8a72e..00bb91ad 100644
--- a/modules/dev-fkeys.el
+++ b/modules/dev-fkeys.el
@@ -8,10 +8,8 @@
;; Eager reason: the F4/F6 developer command entry points.
;; Top-level side effects: six global F-key bindings; conditionally registers a
;; C-; P binding.
-;; Runtime requires: cl-lib, system-lib. keybindings is needed for the C-; P
-;; binding but is declared only via eval-when-compile and guarded by `boundp',
-;; so that binding silently drops standalone. Phase 2 fix.
-;; Direct test load: conditional (C-; P registration skipped without keybindings).
+;; Runtime requires: cl-lib, system-lib, keybindings.
+;; Direct test load: yes (requires keybindings explicitly).
;;
;; Project-aware F-key block for developer workflows:
;;
@@ -54,6 +52,7 @@
(require 'cl-lib)
(require 'system-lib)
+(require 'keybindings) ;; provides cj/custom-keymap
(declare-function projectile-compile-project "projectile" (arg))
(declare-function projectile-run-project "projectile" (arg))
@@ -531,12 +530,7 @@ message."
;; ---------- Bindings ----------
-(eval-when-compile (defvar cj/custom-keymap)) ;; defined in keybindings.el
-
-;; Skip the binding if cj/custom-keymap isn't loaded yet (e.g. when this
-;; module is required directly in batch tests).
-(when (boundp 'cj/custom-keymap)
- (keymap-set cj/custom-keymap "P" #'cj/projectile-reset-cmds))
+(keymap-set cj/custom-keymap "P" #'cj/projectile-reset-cmds)
(keymap-global-set "<f4>" #'cj/f4-compile-and-run)
(keymap-global-set "C-<f4>" #'cj/f4-compile-only)
diff --git a/modules/flycheck-config.el b/modules/flycheck-config.el
index 8932a3ac..5626095c 100644
--- a/modules/flycheck-config.el
+++ b/modules/flycheck-config.el
@@ -10,9 +10,8 @@
;; candidate.
;; Top-level side effects: package configuration via use-package, binds into
;; cj/custom-keymap through use-package :map.
-;; Runtime requires: keybindings is needed for the cj/custom-keymap :map binding
-;; but is not required here; the binding fails standalone. Phase 2 fix.
-;; Direct test load: conditional (needs cj/custom-keymap for the :map binding).
+;; Runtime requires: keybindings.
+;; Direct test load: yes (requires keybindings explicitly).
;;
;; This file configures Flycheck for on-demand syntax and grammar checking.
;; - Flycheck starts automatically only in sh-mode and emacs-lisp-mode
@@ -44,6 +43,8 @@
;;; Code:
+(require 'keybindings) ;; provides cj/custom-keymap (use-package :map below)
+
(defun cj/prose-helpers-on ()
"Ensure that `abbrev-mode' and `flycheck-mode' are on in the current buffer."
(interactive)
diff --git a/modules/mail-config.el b/modules/mail-config.el
index 5050d761..e1ebdfce 100644
--- a/modules/mail-config.el
+++ b/modules/mail-config.el
@@ -10,10 +10,8 @@
;; command-loaded deferral candidate for Phase 5.
;; Top-level side effects: registers cj/email-map under cj/custom-keymap, one
;; add-hook, two advice-add, one global key, package config.
-;; Runtime requires: user-constants, system-lib, mu4e-attachments. keybindings
-;; is needed for the C-; e registration but is not required, so the module
-;; errors standalone. Phase 2 fix.
-;; Direct test load: conditional (needs cj/custom-keymap from keybindings).
+;; Runtime requires: user-constants, system-lib, mu4e-attachments, keybindings.
+;; Direct test load: yes (requires keybindings; mu4e package must be present).
;;
;; I found Aime Bertrand's blog post to be an excellent walkthrough of how to
;; setup a Mu4e config.
@@ -34,6 +32,7 @@
(require 'user-constants)
(require 'system-lib)
(require 'mu4e-attachments)
+(require 'keybindings) ;; provides cj/custom-keymap
;; cj/custom-keymap's real binding is in keybindings.el, which init.el loads
;; first. The use-package org-msg :preface below wraps in eval-and-compile, so
diff --git a/modules/system-defaults.el b/modules/system-defaults.el
index 33d93bbc..8ef6181a 100644
--- a/modules/system-defaults.el
+++ b/modules/system-defaults.el
@@ -11,11 +11,9 @@
;; Top-level side effects: mutates global defaults (many `setq'), advises
;; `display-warning', adds a `display-buffer-alist' entry, remaps one global
;; key.
-;; Runtime requires: autorevert, server, bookmark; host-environment
-;; (`env-bsd-p') and user-constants (`user-home-dir') are read at load but
-;; currently only required via eval-when-compile — Phase 2 to make explicit.
-;; Direct test load: conditional (host-environment and user-constants must load
-;; first; the compiled module cannot resolve them standalone yet).
+;; Runtime requires: autorevert, server, bookmark, host-environment
+;; (`env-bsd-p'), user-constants (`user-home-dir').
+;; Direct test load: yes.
;;
;; Loads during init to set sane defaults: UTF-8 everywhere, quiet prompts, synced clipboards,
;; and hands-off async shell buffers. Nothing to call—just launch Emacs and the environment is ready.
@@ -31,13 +29,12 @@
(require 'server)
(require 'bookmark)
-;; `host-environment' and `user-constants' are loaded earlier in init.el,
-;; so they are available at runtime when this module loads. The
-;; `eval-when-compile' forms here are byte-compile hints to silence
-;; free-variable / free-function warnings when this module is compiled
-;; in isolation; no runtime requires are needed.
-(eval-when-compile (require 'host-environment))
-(eval-when-compile (require 'user-constants))
+;; host-environment (`env-bsd-p') and user-constants (`user-home-dir') are read
+;; at load time below, so require them at runtime, not only at compile time.
+;; init.el already loads them earlier; the explicit requires let this module
+;; load standalone.
+(require 'host-environment)
+(require 'user-constants)
;; -------------------------- Native Comp Preferences --------------------------
diff --git a/modules/transcription-config.el b/modules/transcription-config.el
index 0a4b4b39..566cea49 100644
--- a/modules/transcription-config.el
+++ b/modules/transcription-config.el
@@ -50,9 +50,6 @@
(require 'system-lib) ; provides cj/auth-source-secret-value
(require 'user-constants) ; For cj/audio-file-extensions
-;; Declare keymap defined in keybindings.el
-(eval-when-compile (defvar cj/custom-keymap))
-
;; ----------------------------- Configuration ---------------------------------
(defvar cj/transcribe-backend 'assemblyai
diff --git a/modules/video-audio-recording.el b/modules/video-audio-recording.el
index 38c1931c..cec5df85 100644
--- a/modules/video-audio-recording.el
+++ b/modules/video-audio-recording.el
@@ -10,10 +10,8 @@
;; run only on command (command-loaded target).
;; Top-level side effects: defines cj/record-map and conditionally registers it
;; under C-; r.
-;; Runtime requires: system-lib. keybindings is needed for the C-; r binding but
-;; only reached through a boundp guard, so the binding silently drops
-;; standalone. Phase 2 fix.
-;; Direct test load: conditional (C-; r registration skipped without keybindings).
+;; Runtime requires: system-lib, keybindings.
+;; Direct test load: yes (requires keybindings explicitly).
;;
;; Desktop video and audio recording from within Emacs using ffmpeg.
;; Records from both microphone and system audio simultaneously, which
@@ -109,6 +107,7 @@
;;; Code:
(require 'system-lib)
+(require 'keybindings) ;; provides cj/custom-keymap
;;; ============================================================
;;; Configuration Variables
@@ -1089,9 +1088,7 @@ Changes take effect on the next recording (not the current one)."
map)
"Keymap for video/audio recording operations under C-; r.")
-;; Only bind keys when running interactively (not in batch/test mode)
-(when (boundp 'cj/custom-keymap)
- (keymap-set cj/custom-keymap "r" cj/record-map))
+(keymap-set cj/custom-keymap "r" cj/record-map)
(with-eval-after-load 'which-key
(which-key-add-key-based-replacements