Improve documentation of 'define-keymap'

* lisp/emacs-lisp/shortdoc.el (keymaps): Add example for adding
key bindings to an existing keymap.
* lisp/keymap.el (define-keymap): Doc fix.  (Bug#80556)
This commit is contained in:
Eli Zaretskii
2026-03-07 10:55:23 +02:00
parent 06471a82c8
commit a9eac78e23
2 changed files with 7 additions and 3 deletions

View File

@@ -1586,9 +1586,12 @@ A FUNC form can have any number of `:no-eval' (or `:no-value'),
:no-eval (text-property-search-backward 'face nil t)))
(define-short-documentation-group keymaps
"Defining keymaps"
"Defining keymaps or adding bindings to existing keymaps"
(define-keymap
:no-eval (define-keymap "C-c C-c" #'quit-buffer))
:no-eval (define-keymap "C-c C-c" #'quit-buffer)
:no-eval (define-keymap :keymap ctl-x-map
"C-r" #'recentf-open
"k" #'kill-current-buffer))
(defvar-keymap
:no-eval (defvar-keymap my-keymap "C-c C-c" #'quit-buffer))
"Setting keys"

View File

@@ -609,7 +609,8 @@ pairs. Available keywords are:
(see `set-keymap-parent').
:keymap If non-nil, instead of creating a new keymap, the given keymap
will be destructively modified instead.
will be destructively modified instead. This can be used to
add key bindings to an existing keymap.
:name If non-nil, this should be a string to use as the menu for
the keymap in case you use it as a menu with `x-popup-menu'.