From: Richard M. Stallman Date: Tue, 16 Nov 2004 17:05:18 +0000 (+0000) Subject: (map-keymap-internal): New function. X-Git-Tag: ttn-vms-21-2-B4~3889 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=14694a594bdd37507a8b3861fbf6387b60b742cb;p=emacs.git (map-keymap-internal): New function. --- diff --git a/lisp/subr.el b/lisp/subr.el index d2b836a5e4f..c8dfedbd8c6 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -484,6 +484,24 @@ The order of bindings in a keymap matters when it is used as a menu." (setq inserted t))) (setq tail (cdr tail))))) +(defun map-keymap-internal (function keymap &optional sort-first) + "Implement `map-keymap' with sorting. +Don't call this function; it is for internal use only." + (if sort-first + (let (list) + (map-keymap (lambda (a b) (push (cons a b) list)) + keymap) + (setq list (sort list + (lambda (a b) + (setq a (car a) b (car b)) + (if (integerp a) + (if (integerp b) (< a b) + t) + (if (integerp b) t + (string< a b)))))) + (dolist (p list) + (funcall function (car p) (cdr p)))) + (map-keymap function keymap))) (defmacro kbd (keys) "Convert KEYS to the internal Emacs key representation.