diff options
| author | Craig Jennings <c@cjennings.net> | 2026-09-22 14:29:33 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-09-22 14:29:33 -0400 |
| commit | 7c9f92eb0a6751d04a43ffe3cc5f725fce5ab371 (patch) | |
| tree | 66b997100cfd7067328283e5c7568b1f650cf2a8 | |
| parent | befb206ae7b2daeb61acd20f11aa9d2d5017733f (diff) | |
| download | dotemacs-7c9f92eb0a6751d04a43ffe3cc5f725fce5ab371.tar.gz dotemacs-7c9f92eb0a6751d04a43ffe3cc5f725fce5ab371.zip | |
Stock Emacs binds F11 to toggle-frame-fullscreen, the key every other application uses for it. This config never rebound it, but dirvish-config's :bind put dirvish-side on F11 and shadowed the stock binding. I moved the sidebar toggle to F9, the free bare F-key: ai-term left it for M-SPC in June and the recording chord came off it today. F2 is the preview key and F5 is reserved for the debug backend, so neither was a candidate.
The org-capture F-key guard follows the command rather than the key. F9 joins its list and F11 leaves it, since a fullscreen toggle pops nothing over a capture. The tests pin the new key, the un-shadowed F11, and the guard change.
| -rw-r--r-- | docs/specs/keybinding-console-safety-spec.org | 2 | ||||
| -rw-r--r-- | modules/dirvish-config.el | 10 | ||||
| -rw-r--r-- | modules/org-capture-config.el | 8 | ||||
| -rw-r--r-- | tests/test-dirvish-config--side-key.el | 40 | ||||
| -rw-r--r-- | tests/test-keybindings--fullscreen.el | 45 | ||||
| -rw-r--r-- | tests/test-org-capture-config-fkey-guard.el | 15 |
6 files changed, 112 insertions, 8 deletions
diff --git a/docs/specs/keybinding-console-safety-spec.org b/docs/specs/keybinding-console-safety-spec.org index 5fd7d52c..9781b43a 100644 --- a/docs/specs/keybinding-console-safety-spec.org +++ b/docs/specs/keybinding-console-safety-spec.org @@ -846,7 +846,7 @@ have large package-managed binding lists not enumerated here. - [ ] M-D (dirvish-mode-map) — dwim-shell-commands-menu — (dwim-shell-config.el:934) - [ ] + (dirvish-mode-map) — cj/music-add-dired-selection — (music-config.el:597) - [ ] T (dired/dirvish-mode-map) — cj/transcribe-media-at-point — (transcription-config.el:463/467) - - [ ] <f11> (dirvish-mode-map) — dirvish-side — (dirvish-config.el:481) + - [ ] <f9> (global) — dirvish-side — (dirvish-config.el:661; F11 is stock toggle-frame-fullscreen again as of 2026-09-22) - [ ] Shell / terminal - [ ] C-r (eshell-mode-map) — cj/eshell-history-search — (eshell-config.el:202) - [ ] <up> (eshell-hist-mode-map) — previous-line — (eshell-config.el:99) diff --git a/modules/dirvish-config.el b/modules/dirvish-config.el index 6c849198..e9b9fde6 100644 --- a/modules/dirvish-config.el +++ b/modules/dirvish-config.el @@ -29,7 +29,7 @@ ;; - S: Study — start an org-drill session on the .org file at point ;; - M-D (Meta-Shift-d): DWIM shell commands menu ;; - TAB: Toggle subtree expansion -;; - F11: Toggle sidebar view +;; - F9: Toggle sidebar view ;;; Code: @@ -653,7 +653,13 @@ no popup frame is live." (("C-x d" . dirvish) ("C-x C-d" . dirvish) ("C-x D" . dirvish) - ("<f11>" . dirvish-side) + ;; F9, not F11: F11 is stock Emacs's toggle-frame-fullscreen, the same key + ;; every other application uses, and the sidebar sat on it for years by + ;; shadowing that. F9 is the free bare F-key: ai-term left it for M-SPC + ;; in June 2026 and the recording chord came off it on 2026-09-22. F2 is + ;; the preview key (markdown-mode binds it) and F5 is reserved for the + ;; debug backend, so neither was a candidate. + ("<f9>" . dirvish-side) :map dirvish-mode-map ("bg" . cj/set-wallpaper) ("/" . dirvish-narrow) diff --git a/modules/org-capture-config.el b/modules/org-capture-config.el index b7250f1e..8f5903fe 100644 --- a/modules/org-capture-config.el +++ b/modules/org-capture-config.el @@ -145,12 +145,16 @@ re-scanning large target files after the first successful lookup." :around #'cj/org-capture--set-target-location-advice)) ;; --------------------------- Capture F-Key Guard ----------------------------- -;; The global popup keys (F1 dashboard sweep, F10 music, F11 dirvish-side, +;; The global popup keys (F1 dashboard sweep, F9 dirvish-side, F10 music, ;; F12 terminal, M-SPC agent swap) fire even while a capture is in progress ;; and pop their UI over the capture popup. org-capture-mode is a minor ;; mode active exactly for the capture's duration and its keymap shadows ;; the global map, so blocking the keys there scopes the guard precisely: ;; the moment the capture finalizes or aborts, the keys work again. +;; +;; The list follows the command, not the key. F11 was on it while it held +;; dirvish-side; now that F11 is the frame fullscreen toggle it pops nothing +;; over a capture and stays usable. (defun cj/--org-capture-blocked-key () "Refuse a global popup key while a capture is in progress." @@ -160,7 +164,7 @@ re-scanning large target files after the first successful lookup." (defvar org-capture-mode-map) (with-eval-after-load 'org-capture - (dolist (key '("<f1>" "<f10>" "<f11>" "<f12>" "M-SPC")) + (dolist (key '("<f1>" "<f9>" "<f10>" "<f12>" "M-SPC")) (keymap-set org-capture-mode-map key #'cj/--org-capture-blocked-key))) ;; ----------------------- Project-Aware Capture Target ------------------------ diff --git a/tests/test-dirvish-config--side-key.el b/tests/test-dirvish-config--side-key.el new file mode 100644 index 00000000..1f08314c --- /dev/null +++ b/tests/test-dirvish-config--side-key.el @@ -0,0 +1,40 @@ +;;; test-dirvish-config--side-key.el --- dirvish-side lives on F9 -*- lexical-binding: t; -*- + +;;; Commentary: +;; The sidebar toggle moved from F11 to F9 on 2026-09-22 so F11 could go back +;; to `toggle-frame-fullscreen', the stock binding every other application +;; shares and which the :bind had been shadowing. F9 was the free bare +;; F-key: ai-term left it for M-SPC in June and the recording chord came off +;; it the same day this moved. F2 is the preview key and F5 is reserved for +;; the debug backend, so neither was a candidate. + +;;; Code: + +(require 'ert) +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'keybindings) +(require 'dirvish-config) + +;;; Normal + +(ert-deftest test-dirvish-config-side-on-f9 () + "Normal: F9 toggles the dirvish sidebar." + (should (eq (keymap-lookup global-map "<f9>") #'dirvish-side))) + +;;; Boundary + +(ert-deftest test-dirvish-config-side-not-on-f11 () + "Boundary/regression: F11 no longer reaches dirvish-side, so the stock +`toggle-frame-fullscreen' binding is no longer shadowed." + (should-not (eq (keymap-lookup global-map "<f11>") #'dirvish-side)) + (should (eq (keymap-lookup global-map "<f11>") #'toggle-frame-fullscreen))) + +;;; Error + +(ert-deftest test-dirvish-config-side-target-is-a-command () + "Error (positive control): the binding points at a real interactive +command, so a keypress does not fail with a `commandp' error at press time." + (should (commandp (keymap-lookup global-map "<f9>")))) + +(provide 'test-dirvish-config--side-key) +;;; test-dirvish-config--side-key.el ends here diff --git a/tests/test-keybindings--fullscreen.el b/tests/test-keybindings--fullscreen.el new file mode 100644 index 00000000..c35e398c --- /dev/null +++ b/tests/test-keybindings--fullscreen.el @@ -0,0 +1,45 @@ +;;; test-keybindings--fullscreen.el --- F11 toggles frame fullscreen -*- lexical-binding: t; -*- + +;;; Commentary: +;; Stock Emacs binds F11 to `toggle-frame-fullscreen', the same key every +;; other application on the desktop uses for it. This config never rebound +;; it; dirvish-config's :bind put dirvish-side on F11 and shadowed the stock +;; binding for as long as that entry existed. It moved to F9 on 2026-09-22 +;; (see test-dirvish-config--side-key.el, which pins the un-shadowing). +;; +;; These tests pin the foundation layer's side of that: keybindings.el must +;; leave the stock F11 binding in place. Only keybindings.el is loaded here +;; on purpose. A feature module that later claimed F11 would fail the +;; dirvish-side regression test, not this one. + +;;; Code: + +(require 'ert) +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'keybindings) + +;;; Normal + +(ert-deftest test-keybindings-f11-toggles-fullscreen () + "Normal: F11 runs `toggle-frame-fullscreen' once the foundation layer has +loaded. Stock Emacs provides the binding; this pins that keybindings.el does +not unset or rebind it." + (should (eq (keymap-lookup global-map "<f11>") #'toggle-frame-fullscreen))) + +;;; Boundary + +(ert-deftest test-keybindings-f11-is-the-only-fullscreen-chord () + "Boundary: the plain key carries it; the shifted chord is left free so a +grazed Shift does not toggle the frame twice." + (should-not (eq (keymap-lookup global-map "S-<f11>") + #'toggle-frame-fullscreen))) + +;;; Error + +(ert-deftest test-keybindings-f11-target-is-a-command () + "Error (positive control): the target is a real interactive command, so a +press does not fail with a `commandp' error at press time." + (should (commandp (keymap-lookup global-map "<f11>")))) + +(provide 'test-keybindings--fullscreen) +;;; test-keybindings--fullscreen.el ends here diff --git a/tests/test-org-capture-config-fkey-guard.el b/tests/test-org-capture-config-fkey-guard.el index b288ce4f..c0687bb2 100644 --- a/tests/test-org-capture-config-fkey-guard.el +++ b/tests/test-org-capture-config-fkey-guard.el @@ -2,8 +2,10 @@ ;;; Commentary: ;; While a capture is in progress, the global popup keys (F1 dashboard -;; sweep, F10 music, F11 dirvish-side, F12 terminal, M-SPC agent swap) -;; must not fire and pop UI over the capture. org-capture-mode is a +;; sweep, F9 dirvish-side, F10 music, F12 terminal, M-SPC agent swap) +;; must not fire and pop UI over the capture. F11 is deliberately not on +;; the list: it toggles frame fullscreen, which pops nothing over the +;; capture, so blocking it would only get in the way. org-capture-mode is a ;; minor mode active exactly for the capture's duration and its keymap ;; shadows the global map, so the guard binds those keys there to a ;; blocker that signals a `user-error' naming the way out. @@ -21,10 +23,17 @@ (ert-deftest test-org-capture-fkey-guard-keys-bound () "Normal: every leaking popup key is bound to the blocker in capture mode." - (dolist (key '("<f1>" "<f10>" "<f11>" "<f12>" "M-SPC")) + (dolist (key '("<f1>" "<f9>" "<f10>" "<f12>" "M-SPC")) (should (eq (keymap-lookup org-capture-mode-map key) #'cj/--org-capture-blocked-key)))) +(ert-deftest test-org-capture-fkey-guard-leaves-fullscreen-alone () + "Boundary: F11 (frame fullscreen) is not blocked. It pops no UI, and +before dirvish-side moved to F9 it was on this list only because F11 was the +sidebar key; the entry must follow the command, not the key." + (should-not (eq (keymap-lookup org-capture-mode-map "<f11>") + #'cj/--org-capture-blocked-key))) + (ert-deftest test-org-capture-fkey-guard-blocker-signals-user-error () "Error: the blocker signals a user-error rather than doing nothing." (should-error (cj/--org-capture-blocked-key) :type 'user-error)) |
