Keymap Prompts

2021, Summer

If you bind a key to a keymap, and not an interactive function, Emacs will display a useful prompt in the echo area. Quite handy for rarely used keymaps with only a few bindings.

This is (of course) well documented in the Emacs info manuals, but my discovery of it should be credited to u/oantolin on reddit.

(setq pkg-ops-map (let ((map (make-sparse-keymap "Packages"))) (define-key map "h" '("describe" . describe-package)) (define-key map "a" '("autoremove" . package-autoremove)) (define-key map "d" '("delete" . package-delete)) (define-key map "i" '("install" . package-install)) (define-key map "s" '("selected" . package-install-selected-packages)) (define-key map "r" '("refresh" . package-refresh-contents)) (define-key map "l" '("list" . list-packages)) map)) (global-set-key (kbd "C-c p") pkg-ops-map)