Function: bindings--sort-menu-keymap
bindings--sort-menu-keymap is a byte-compiled function defined in
bindings.el.gz.
Signature
(bindings--sort-menu-keymap MAP)
Documentation
Sort the bindings in MAP in alphabetical order by menu-item string.
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.
Source Code
;; Defined in /usr/src/emacs/lisp/bindings.el.gz
(defun bindings--sort-menu-keymap (map)
"Sort the bindings in MAP in alphabetical order by menu-item string.
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."
(let ((bindings nil)
(prompt (keymap-prompt map)))
(while (keymapp map)
(setq map (map-keymap
(lambda (key item)
;; FIXME: Handle char-ranges here?
(push (cons key item) bindings))
map)))
;; Sort the bindings and make a new keymap from them.
(setq bindings
(sort bindings
(lambda (a b)
(string< (bindings--menu-item-string (cdr-safe a))
(bindings--menu-item-string (cdr-safe b))))))
(nconc (make-sparse-keymap prompt) bindings)))