I am writing my first minor mode, and would like to understand how to bind a key to an action in that mode.
(define-minor-mode hello-mode "My Mode" :init-value nil :lighter " Hello" :keymap (let ((map (make-sparse-keymap))) (define-key map (kbd "M-p") (lambda () (interactive) (message "HI!!!"))) map) :group 'hello)
After running this followed by
M-x hello-mode (or
(hello-mode t)), I would hope that hitting
M-p would display
"HI!!!" in the echo area, but Emacs tells me
M-p is still undefined.
What else is needed to bind a key to a function when my minor mode is active?