diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-03 16:13:21 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-03 16:13:21 -0500 |
| commit | 2c94acd52cc92dc4ebefd999dbca771367cc3090 (patch) | |
| tree | 2c9ed2df067e736c98c0b7fa36ed3655d8b85e16 /modules/prog-general.el | |
| parent | 8ec668d6749b22f47a4c614d0965445dcfa86f50 (diff) | |
| download | dotemacs-2c94acd52cc92dc4ebefd999dbca771367cc3090.tar.gz dotemacs-2c94acd52cc92dc4ebefd999dbca771367cc3090.zip | |
feat(dev-fkeys): add project-aware F4 compile/run dispatcher
I added a new module `modules/dev-fkeys.el` that owns the dev F-key block. F4 prompts via `completing-read` with a candidate set filtered by project type (compiled / interpreted / unknown). C-F4 is the compile-only fast path. M-F4 is clean + rebuild. It runs a heuristic clean command derived from the project markers (go.mod, Cargo.toml, Eask, Makefile, CMakeLists.txt) and chains `projectile-compile-project` on success. S-F4 stays on `recompile` and now lives globally instead of duplicated across prog-general.el and prog-c.el. F6 is bound globally to `projectile-test-project` as a Phase 1 stopgap. Phase 2 replaces it with the polyglot test runner spec'd in todo.org.
Project-type detection runs against the projectile root and falls back to `unknown` when no marker matches. Interpreted markers are checked first so a Python or Node project with a Makefile for tasks classifies as interpreted instead of compiled. Compile + Run sequencing uses a one-shot `compilation-finish-functions` hook that self-removes on first invocation and only fires the follow-up when the status string starts with `finished`.
Cleanup in the same commit:
- Dropped F4/F5/F6 from `prog-general.el`'s prog-mode-hook. They are now global.
- Dropped F6→format bindings from prog-c.el / prog-python.el / prog-shell.el. C-; f was already bound in each, so this is pure removal.
- Dropped the duplicate S-F4 from prog-c.el. The global binding covers it.
- Updated the keybinding header in prog-general.el and the workflow comments in prog-c.el / prog-shell.el.
- Wired `(require 'dev-fkeys)` in init.el alongside coverage-core.
TDD: 73 tests across 11 files, one per helper. Production code is split into small testable internals (`cj/--detect-project-type`, `cj/--f4-candidates`, `cj/--f4-derive-clean-cmd`, `cj/--f4-make-once-hook`, `cj/--f4-dispatch`, `cj/--f4-compile-and-run-impl`, `cj/--f4-clean-rebuild-impl`, `cj/--f4-project-root`) plus three thin interactive wrappers. Smoke tests confirm bindings register on load.
Known limitation: if another `compilation-finish-functions` hook fires between my add-hook and the compile finishing, the chain can fire on the wrong compile. The hook self-removes on first invocation regardless of which compile it sees. Documented in the impl docstring. Acceptable for v1.
Phase 2 will replace F6 with the polyglot test runner (tree-sitter queries for Python/Go/TS, sexp scan for Elisp, buffer-local last-test memory).
Diffstat (limited to 'modules/prog-general.el')
| -rw-r--r-- | modules/prog-general.el | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/modules/prog-general.el b/modules/prog-general.el index 0ae6aa82..46599cc9 100644 --- a/modules/prog-general.el +++ b/modules/prog-general.el @@ -8,28 +8,22 @@ ;; ;; Keybinding Scheme: ;; ------------------ -;; Unified keybindings across all programming languages using Projectile -;; for project-aware operations with language-specific overrides. +;; The F4–F7 dev block is owned by dev-fkeys.el (global bindings). Per- +;; language modules only set S-F5 / S-F6 overrides for static analysis +;; and debugging. F5 is reserved for the debug ticket. ;; -;; Global Keybindings (all prog-mode buffers): -;; F4 - projectile-compile-project (smart compilation) -;; S-F4 - recompile (repeat last compile) -;; F5 - projectile-test-project (run tests) -;; S-F5 - Language-specific static analysis -;; F6 - projectile-run-project (run/execute) -;; S-F6 - Language-specific debugger -;; C-; f - Language-specific formatter +;; Global (dev-fkeys.el): +;; F4 / C-F4 / M-F4 compile + run dispatcher / compile only / clean + rebuild +;; S-F4 recompile (repeat last) +;; F6 project tests (Phase 1 stopgap; Phase 2 = polyglot dispatcher) +;; F7 coverage report (coverage-core.el) +;; C-; f language-specific formatter ;; -;; Quick Reference Table: -;; | Key | Global | C | Go | Python | Shell | -;; |-------|----------|---------------|-------------|-------------|-------------| -;; | F4 | compile | compile | compile | compile | compile | -;; | S-F4 | recompile| recompile | (projectile)| (projectile)| (projectile)| -;; | F5 | test | test | test | test | test | -;; | S-F5 | (none) | disabled | staticcheck | mypy | shellcheck | -;; | F6 | run | run | run | run | run | -;; | S-F6 | (none) | gdb | dlv | pdb | disabled | -;; | C-; f | format | clang-format | gofmt | blacken | shfmt | +;; Per-language S-modifier overrides: +;; | Key | C | Go | Python | Shell | +;; |------|----------|-------------|--------|------------| +;; | S-F5 | disabled | staticcheck | mypy | shellcheck | +;; | S-F6 | gdb | dlv | pdb | disabled | ;;; Code: @@ -79,11 +73,9 @@ (auto-fill-mode) ;; auto wrap at the fill column set (local-set-key (kbd "M-;") 'comment-dwim) ;; comment/uncomment region as appropriate - ;; Project-wide commands (can be overridden by language-specific modes) - (local-set-key (kbd "<f4>") 'projectile-compile-project) ;; compile project - (local-set-key (kbd "S-<f4>") 'recompile) ;; recompile (repeat last) - (local-set-key (kbd "<f5>") 'projectile-test-project) ;; run tests - (local-set-key (kbd "<f6>") 'projectile-run-project)) ;; run project + ;; F4–F6 are global, owned by dev-fkeys.el. F5 is reserved for the + ;; debug ticket (separate work). + ) (add-hook 'prog-mode-hook #'cj/general-prog-settings) (add-hook 'html-mode-hook #'cj/general-prog-settings) |
