I am a long time evil-mode Spacemacs user, but now would like to roll my own config that copies my favourite parts of Spacemacs. I’m having some trouble with Keybindings for major modes.
I’m using Emacs 29. I’ve not needed general.el so far. Following this advice for using the newer Emacs 29 keybindings –
here. I’ve had success using keymap-set
and which-key-add-keymap-based-replacements
. Here’s part of my config for the File keybindings I’ve configured, which works as expected:
(defvar-keymap my-files-keymap
:doc "Key map for file functions"
"f" #'find-file
"s" #'save-buffer)
;;Add new key map to the leader
(keymap-set my-leader-map "f" my-files-keymap)
;;Add labels to the Files keymaps
(which-key-add-keymap-based-replacements my-files-keymap
"f" "find"
"s" "save")
;;Add Files to the Leader keymaps
(which-key-add-keymap-based-replacements my-leader-map
"f" "Files")
But what I don’t understand is how to add keybindings for major modes. For example, when in org mode I’d like SPC, m to show the major mode keybindings that I want for org mode. But when in a different major mode, such as Clojure mode, I’d like SPC, m to show just the keybindings relevant to Clojure.
Can someone show an example for doing that with the new Emacs 29 functions, or link to an example that does that, please?