mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Lift define-prefix-command to Lisp
* lisp/subr.el (define-prefix-command): New defun. * src/keymap.c (Fdefine_prefix_command): Remove DEFUN. (syms_of_keymap): Remove defsubr for Fdefine_prefix_command. * test/lisp/subr-tests.el (subr-test-define-prefix-command): New test.
This commit is contained in:
parent
f5cfe5a0a9
commit
5ac7b48075
3 changed files with 27 additions and 23 deletions
16
lisp/subr.el
16
lisp/subr.el
|
|
@ -995,6 +995,22 @@ a menu, so this function is not useful for non-menu keymaps."
|
|||
(setq inserted t)))
|
||||
(setq tail (cdr tail)))))
|
||||
|
||||
(defun define-prefix-command (command &optional mapvar name)
|
||||
"Define COMMAND as a prefix command. COMMAND should be a symbol.
|
||||
A new sparse keymap is stored as COMMAND's function definition and its
|
||||
value.
|
||||
This prepares COMMAND for use as a prefix key's binding.
|
||||
If a second optional argument MAPVAR is given, it should be a symbol.
|
||||
The map is then stored as MAPVAR's value instead of as COMMAND's
|
||||
value; but COMMAND is still defined as a function.
|
||||
The third optional argument NAME, if given, supplies a menu name
|
||||
string for the map. This is required to use the keymap as a menu.
|
||||
This function returns COMMAND."
|
||||
(let ((map (make-sparse-keymap name)))
|
||||
(fset command map)
|
||||
(set (or mapvar command) map)
|
||||
command))
|
||||
|
||||
(defun map-keymap-sorted (function keymap)
|
||||
"Implement `map-keymap' with sorting.
|
||||
Don't call this function; it is for internal use only."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue