From dbce94b38f3267e59b015880d34ff31104126e47 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 3 May 2026 17:58:42 -0500 Subject: feat(dev-fkeys): propagate prefix-arg to projectile through F4 / F6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I had four call sites passing literal nil to `projectile-compile-project' / `projectile-run-project' / `projectile-test-project'. The literal nil ignored whatever prefix arg the user gave. So `C-u F4 → Compile' or `C-u F6 → All tests' didn't actually force projectile's re-prompt — the prefix arg got swallowed at our wrapper layer. Switched all four to `current-prefix-arg': - `cj/--f4-dispatch' — `compile-only' and `run-only' actions. - `cj/f4-compile-only' — the C-F4 fast path's compiled-project branch. - `cj/f6-test-runner' — the "All tests" menu entry. Use case: when projectile's cached cmd is wrong (typo, stale, or whatever), `C-u' on any of these forces projectile to re-prompt instead of replaying the bad cmd silently. The compile-and-run and clean-rebuild paths still pass nil to their chained projectile calls because those run inside an async `compilation-finish-functions' hook, where `current-prefix-arg' has already reverted to nil. Refining those would need to capture the prefix at entry and thread it through; left for later. TDD: 4 new tests (one per call site) bind `current-prefix-arg' to t and verify projectile receives t. Each test failed against the literal-nil version and passes against `current-prefix-arg'. --- tests/test-dev-fkeys--f4-dispatch.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/test-dev-fkeys--f4-dispatch.el') diff --git a/tests/test-dev-fkeys--f4-dispatch.el b/tests/test-dev-fkeys--f4-dispatch.el index 774daebf..0bf667a7 100644 --- a/tests/test-dev-fkeys--f4-dispatch.el +++ b/tests/test-dev-fkeys--f4-dispatch.el @@ -23,6 +23,26 @@ (cj/--f4-dispatch 'compile-only) (should (= calls 1))))) +(ert-deftest test-dev-fkeys-dispatch-compile-only-propagates-prefix-arg () + "Normal: 'compile-only forwards `current-prefix-arg' to +projectile-compile-project so `C-u F4 → Compile' forces a re-prompt." + (let ((seen-arg 'unset) + (current-prefix-arg t)) + (cl-letf (((symbol-function 'projectile-compile-project) + (lambda (arg) (setq seen-arg arg)))) + (cj/--f4-dispatch 'compile-only) + (should (eq seen-arg t))))) + +(ert-deftest test-dev-fkeys-dispatch-run-only-propagates-prefix-arg () + "Normal: 'run-only forwards `current-prefix-arg' to +projectile-run-project." + (let ((seen-arg 'unset) + (current-prefix-arg t)) + (cl-letf (((symbol-function 'projectile-run-project) + (lambda (arg) (setq seen-arg arg)))) + (cj/--f4-dispatch 'run-only) + (should (eq seen-arg t))))) + (ert-deftest test-dev-fkeys-dispatch-run-only-calls-projectile-run () "Normal: 'run-only routes to projectile-run-project." (let ((calls 0)) -- cgit v1.2.3