aboutsummaryrefslogtreecommitdiff
path: root/modules/custom-comments.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-03 21:17:30 -0500
committerCraig Jennings <c@cjennings.net>2026-05-03 21:17:30 -0500
commit2f8d8989856073cbed5f9159d02089903bc5343e (patch)
tree1ab81336390846105c92debcc8e788d0d5905e22 /modules/custom-comments.el
parent31edc86a54d20c3c73d0ebad247fde2c35e6a964 (diff)
downloaddotemacs-2f8d8989856073cbed5f9159d02089903bc5343e.tar.gz
dotemacs-2f8d8989856073cbed5f9159d02089903bc5343e.zip
refactor: defer projectile revert advice until projectile loads
`dev-fkeys.el` was wiring its three Projectile cache-revert advices via top-level `advice-add` calls using `apply-partially #'cj/--projectile-around-revert <map-symbol>`. That had three problems. The advice values were anonymous closures, so `advice-member-p` couldn't find them and a re-load would silently double-install. The implicit dependency on Projectile was load-ordered by accident. If `dev-fkeys.el` happened to require before Projectile loaded, the advice still attached to unbound symbols. And a fresh batch require of `dev-fkeys.el` for tests would always force the advice attempt regardless of whether Projectile was around. I gave each Projectile target a named advice wrapper (`cj/--projectile-compile-around-revert`, `cj/--projectile-test-around-revert`, `cj/--projectile-run-around-revert`) and put the (target . advice) pairs in a `cj/--projectile-revert-advice-specs` defconst. `cj/--projectile-install-revert-advice` walks the specs, checks `fboundp` plus `advice-member-p`, and only adds advice that's missing. The installer is idempotent on reload, and the named wrappers make it easy to tear down later by symbol name. `cj/--projectile-register-revert-advice` is the entry point at module load time. It installs immediately when Projectile is already a `featurep`, otherwise it schedules the installer through `eval-after-load 'projectile`. Either way the advice is in place once Projectile is available, and `dev-fkeys.el` no longer relies on a particular load order. Tests in the new `tests/test-dev-fkeys--projectile-advice-install.el` cover four cases. Registration defers via `eval-after-load` when Projectile isn't a feature yet. Registration installs immediately when it is. Install skips unbound Projectile functions. Install advises each bound Projectile command runner with the matching named wrapper. 23 projectile-related tests pass together.
Diffstat (limited to 'modules/custom-comments.el')
0 files changed, 0 insertions, 0 deletions