Function: keymap-set-after
keymap-set-after is a byte-compiled function defined in keymap.el.gz.
Signature
(keymap-set-after KEYMAP KEY DEFINITION &optional AFTER)
Documentation
Add binding in KEYMAP for KEY => DEFINITION, right after AFTER's binding.
This is like keymap-set except that the binding for KEY is placed
just after the binding for the event AFTER, instead of at the beginning
of the map. Note that AFTER must be an event type (like KEY), NOT a command
(like DEFINITION).
If AFTER is t or omitted, the new binding goes at the end of the keymap. AFTER should be a single event type--a symbol or a character, not a sequence.
Bindings are always added before any inherited map.
The order of bindings in a keymap matters only when it is used as a menu, so this function is not useful for non-menu keymaps.
Other relevant functions are documented in the keymaps group.
Probably introduced at or before Emacs version 29.1.
Shortdoc
;; keymaps
(keymap-set-after map "<separator-2>" menu-bar-separator)
Source Code
;; Defined in /usr/src/emacs/lisp/keymap.el.gz
(defun keymap-set-after (keymap key definition &optional after)
"Add binding in KEYMAP for KEY => DEFINITION, right after AFTER's binding.
This is like `keymap-set' except that the binding for KEY is placed
just after the binding for the event AFTER, instead of at the beginning
of the map. Note that AFTER must be an event type (like KEY), NOT a command
\(like DEFINITION).
If AFTER is t or omitted, the new binding goes at the end of the keymap.
AFTER should be a single event type--a symbol or a character, not a sequence.
Bindings are always added before any inherited map.
The order of bindings in a keymap matters only when it is used as
a menu, so this function is not useful for non-menu keymaps."
(declare (indent defun)
(compiler-macro (lambda (form) (keymap--compile-check key) form)))
(keymap--check key)
(when (eq after t) (setq after nil)) ; nil and t are treated the same
(when (stringp after)
(keymap--check after)
(setq after (key-parse after)))
;; If we're binding this key to another key, then parse that other
;; key, too.
(when (stringp definition)
(keymap--check definition)
(setq definition (key-parse definition)))
(define-key-after keymap (key-parse key) definition
after))