From e7b8c249b67ee999e506918a10ce7dd56e45ded0 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 20 Feb 2026 13:31:36 -0600 Subject: fix(mousetrap): use buffer-local keymaps via emulation-mode-map-alists minor-mode-map-alist is global, so the last buffer to set its keymap won for all buffers. Dashboard's scroll+primary profile was immediately overwritten by other buffers' disabled profile. Switch to emulation-mode-map-alists with a buffer-local variable so each buffer gets its own independent keymap. Fixes dashboard click navigation. --- tests/test-integration-mousetrap-mode-lighter-click.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/test-integration-mousetrap-mode-lighter-click.el') diff --git a/tests/test-integration-mousetrap-mode-lighter-click.el b/tests/test-integration-mousetrap-mode-lighter-click.el index b9f32fda..252e0cf5 100644 --- a/tests/test-integration-mousetrap-mode-lighter-click.el +++ b/tests/test-integration-mousetrap-mode-lighter-click.el @@ -35,7 +35,7 @@ Dashboard uses scroll+primary profile which allows scrolling and mouse-1." (should (eq (lookup-key mouse-trap-mode-map (kbd "")) nil)) ;; Keymap should be in minor-mode-map-alist - (should (assq 'mouse-trap-mode minor-mode-map-alist))))) + (should (assq 'mouse-trap-mode mouse-trap--emulation-alist))))) (ert-deftest test-integration-lighter-click-disables-mode () "Test clicking lighter when mode is enabled disables it and removes keymap." @@ -43,7 +43,7 @@ Dashboard uses scroll+primary profile which allows scrolling and mouse-1." (emacs-lisp-mode) (mouse-trap-mode 1) (should mouse-trap-mode) - (should (assq 'mouse-trap-mode minor-mode-map-alist)) + (should (assq 'mouse-trap-mode mouse-trap--emulation-alist)) ;; Simulate clicking lighter to disable (mouse-trap-mode -1) @@ -52,7 +52,7 @@ Dashboard uses scroll+primary profile which allows scrolling and mouse-1." (should-not mouse-trap-mode) ;; Keymap should be removed from minor-mode-map-alist - (should-not (assq 'mouse-trap-mode minor-mode-map-alist)))) + (should-not (assq 'mouse-trap-mode mouse-trap--emulation-alist)))) (ert-deftest test-integration-lighter-click-toggle-updates-keymap () "Test toggling mode via lighter click rebuilds keymap for current mode. @@ -142,12 +142,12 @@ Auto-enable is blocked, but manual toggle should still work." ;; But manual toggle should work (mouse-trap-mode 1) (should mouse-trap-mode) - (should (assq 'mouse-trap-mode minor-mode-map-alist)) + (should (assq 'mouse-trap-mode mouse-trap--emulation-alist)) ;; Toggle off (mouse-trap-mode -1) (should-not mouse-trap-mode) - (should-not (assq 'mouse-trap-mode minor-mode-map-alist)))) + (should-not (assq 'mouse-trap-mode mouse-trap--emulation-alist)))) (ert-deftest test-integration-lighter-click-multiple-rapid-toggles () "Test rapid clicking (multiple toggles) is stable and doesn't corrupt state." @@ -162,12 +162,12 @@ Auto-enable is blocked, but manual toggle should still work." ;; Should end in disabled state (even number of toggles) (should-not mouse-trap-mode) - (should-not (assq 'mouse-trap-mode minor-mode-map-alist)) + (should-not (assq 'mouse-trap-mode mouse-trap--emulation-alist)) ;; Enable one more time to end enabled (mouse-trap-mode 1) (should mouse-trap-mode) - (should (assq 'mouse-trap-mode minor-mode-map-alist)) + (should (assq 'mouse-trap-mode mouse-trap--emulation-alist)) (should (keymapp mouse-trap-mode-map)))) (provide 'test-integration-mousetrap-mode-lighter-click) -- cgit v1.2.3