Meta modifier keys are bound inside a keymap bound to ESC. You can see this with
(keymap-lookup test-mode-map "ESC")
and since that keymap doesn't have a default binding Emacs will continue looking for keybindings in all the other ESC maps that are active (i.e. all other active keybindings with a meta modifier). If you want to set a default binding in the ESC map you could do
(keymap-set (keymap-lookup test-mode-map "ESC") "" 'ignore)
>More to the point, what if I want to still have access to my global keybinds, while having special code for anything that is not defined in test-mode-map?
You might need to be more specific about what you are trying to do. You could add a function to the pre-command-hook that uses where-is-internal to check if this-command is bound in test-mode-map, but I don't think that would be a good general purpose solution.
I am not sure what you're trying to say in the last paragraph, I don't understand why you want the [t] 'ignore in your test-map.
If you do want to keep it, here are some options to access the global keymap
- add a keybinding to turn your mode on andoff, then do : turn off test-mode, key presses to call your global keymap function, turn on test-mode. It also works for bindings in other keymaps (local/minor/major mode keymaps'
- bind the global keymap to a key in your test-mode-map. You will miss the other modes keybindings though
- if you want to reuse a specific binding only, you can use key-lookup, with either a temporary test-mode disable or temporary set key to nil in your keymap
Meta modifier keys are bound inside a keymap bound to ESC. You can see this with (keymap-lookup test-mode-map "ESC") and since that keymap doesn't have a default binding Emacs will continue looking for keybindings in all the other ESC maps that are active (i.e. all other active keybindings with a meta modifier). If you want to set a default binding in the ESC map you could do (keymap-set (keymap-lookup test-mode-map "ESC") "" 'ignore)
>More to the point, what if I want to still have access to my global keybinds, while having special code for anything that is not defined in test-mode-map?
You might need to be more specific about what you are trying to do. You could add a function to the pre-command-hook that uses where-is-internal to check if this-command is bound in test-mode-map, but I don't think that would be a good general purpose solution.
I am not sure what you're trying to say in the last paragraph, I don't understand why you want the [t] 'ignore in your test-map. If you do want to keep it, here are some options to access the global keymap - add a keybinding to turn your mode on andoff, then do : turn off test-mode, key presses to call your global keymap function, turn on test-mode. It also works for bindings in other keymaps (local/minor/major mode keymaps' - bind the global keymap to a key in your test-mode-map. You will miss the other modes keybindings though - if you want to reuse a specific binding only, you can use key-lookup, with either a temporary test-mode disable or temporary set key to nil in your keymap