Function: describe-buffer-bindings
describe-buffer-bindings is a function defined in keymap.c.
Signature
(describe-buffer-bindings BUFFER &optional PREFIX MENUS)
Documentation
Insert the list of all defined keys and their definitions.
The list is inserted in the current buffer, while the bindings are
looked up in BUFFER.
The optional argument PREFIX, if non-nil, should be a key sequence;
then we display only bindings that start with that prefix.
The optional argument MENUS, if non-nil, says to mention menu bindings.
(Ordinarily these are omitted from the output.)
Probably introduced at or before Emacs version 22.1.
Source Code
// Defined in /usr/src/emacs/src/keymap.c
// Skipping highlighting due to helpful-max-highlight.
{
Lisp_Object nomenu = NILP (menus) ? Qt : Qnil;
const char *alternate_heading
= "\
Keyboard translations:\n\n\
You type Translation\n\
-------- -----------\n";
CHECK_BUFFER (buffer);
Lisp_Object shadow = Qnil;
Lisp_Object outbuf = Fcurrent_buffer ();
/* Report on alternates for keys. */
if (STRINGP (KVAR (current_kboard, Vkeyboard_translate_table)) && !NILP (prefix))
{
const unsigned char *translate = SDATA (KVAR (current_kboard, Vkeyboard_translate_table));
int translate_len = SCHARS (KVAR (current_kboard, Vkeyboard_translate_table));
for (int c = 0; c < translate_len; c++)
if (translate[c] != c)
{
char buf[KEY_DESCRIPTION_SIZE];
char *bufend;
if (alternate_heading)
{
insert_string (alternate_heading);
alternate_heading = 0;
}
bufend = push_key_description (translate[c], buf);
insert (buf, bufend - buf);
Findent_to (make_fixnum (16), make_fixnum (1));
bufend = push_key_description (c, buf);
insert (buf, bufend - buf);
insert ("\n", 1);
/* Insert calls signal_after_change which may GC. */
translate = SDATA (KVAR (current_kboard, Vkeyboard_translate_table));
}
insert ("\n", 1);
}
if (!NILP (Vkey_translation_map))
{
Lisp_Object msg = build_unibyte_string ("Key translations");
CALLN (Ffuncall,
Qhelp__describe_map_tree,
Vkey_translation_map, Qnil, Qnil, prefix,
msg, nomenu, Qt, Qnil, Qnil, buffer);
}
/* Print the (major mode) local map. */
Lisp_Object start1 = Qnil;
if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
start1 = KVAR (current_kboard, Voverriding_terminal_local_map);
if (!NILP (start1))
{
Lisp_Object msg = build_unibyte_string ("\f\nOverriding Bindings");
CALLN (Ffuncall,
Qhelp__describe_map_tree,
start1, Qt, shadow, prefix,
msg, nomenu, Qnil, Qnil, Qnil, buffer);
shadow = Fcons (start1, shadow);
start1 = Qnil;
}
else if (!NILP (Voverriding_local_map))
start1 = Voverriding_local_map;
if (!NILP (start1))
{
Lisp_Object msg = build_unibyte_string ("\f\nOverriding Bindings");
CALLN (Ffuncall,
Qhelp__describe_map_tree,
start1, Qt, shadow, prefix,
msg, nomenu, Qnil, Qnil, Qnil, buffer);
shadow = Fcons (start1, shadow);
}
else
{
/* Print the minor mode and major mode keymaps. */
Lisp_Object *modes, *maps;
/* Temporarily switch to `buffer', so that we can get that buffer's
minor modes correctly. */
Fset_buffer (buffer);
int nmaps = current_minor_maps (&modes, &maps);
Fset_buffer (outbuf);
start1 = get_local_map (BUF_PT (XBUFFER (buffer)),
XBUFFER (buffer), Qkeymap);
if (!NILP (start1))
{
Lisp_Object msg = build_unibyte_string ("\f\n`keymap' Property Bindings");
CALLN (Ffuncall,
Qhelp__describe_map_tree,
start1, Qt, shadow, prefix,
msg, nomenu, Qnil, Qnil, Qnil, buffer);
shadow = Fcons (start1, shadow);
}
/* Print the minor mode maps. */
for (int i = 0; i < nmaps; i++)
{
/* The title for a minor mode keymap
is constructed at run time.
We let `help--describe-map-tree' do the actual insertion
because it takes care of other features when doing so. */
char *title, *p;
if (!SYMBOLP (modes[i]))
emacs_abort ();
USE_SAFE_ALLOCA;
p = title = SAFE_ALLOCA (42 + SBYTES (SYMBOL_NAME (modes[i])));
*p++ = '\f';
*p++ = '\n';
*p++ = '`';
memcpy (p, SDATA (SYMBOL_NAME (modes[i])),
SBYTES (SYMBOL_NAME (modes[i])));
p += SBYTES (SYMBOL_NAME (modes[i]));
*p++ = '\'';
memcpy (p, " Minor Mode Bindings", strlen (" Minor Mode Bindings"));
p += strlen (" Minor Mode Bindings");
*p = 0;
Lisp_Object msg = build_unibyte_string (title);
CALLN (Ffuncall,
Qhelp__describe_map_tree,
maps[i], Qt, shadow, prefix,
msg, nomenu, Qnil, Qnil, Qnil, buffer);
shadow = Fcons (maps[i], shadow);
SAFE_FREE ();
}
start1 = get_local_map (BUF_PT (XBUFFER (buffer)),
XBUFFER (buffer), Qlocal_map);
if (!NILP (start1))
{
if (EQ (start1, BVAR (XBUFFER (buffer), keymap)))
{
Lisp_Object msg =
CALLN (Fformat,
build_unibyte_string ("\f\n`%s' Major Mode Bindings"),
XBUFFER (buffer)->major_mode_);
CALLN (Ffuncall,
Qhelp__describe_map_tree,
start1, Qt, shadow, prefix,
msg, nomenu, Qnil, Qnil, Qnil, buffer);
}
else
{
Lisp_Object msg = build_unibyte_string ("\f\n`local-map' Property Bindings");
CALLN (Ffuncall,
Qhelp__describe_map_tree,
start1, Qt, shadow, prefix,
msg, nomenu, Qnil, Qnil, Qnil, buffer);
}
shadow = Fcons (start1, shadow);
}
}
Lisp_Object msg = build_unibyte_string ("\f\nGlobal Bindings");
CALLN (Ffuncall,
Qhelp__describe_map_tree,
current_global_map, Qt, shadow, prefix,
msg, nomenu, Qnil, Qt, Qnil, buffer);
/* Print the function-key-map translations under this prefix. */
if (!NILP (KVAR (current_kboard, Vlocal_function_key_map)))
{
Lisp_Object msg = build_unibyte_string ("\f\nFunction key map translations");
CALLN (Ffuncall,
Qhelp__describe_map_tree,
KVAR (current_kboard, Vlocal_function_key_map), Qnil, Qnil, prefix,
msg, nomenu, Qt, Qnil, Qnil, buffer);
}
/* Print the input-decode-map translations under this prefix. */
if (!NILP (KVAR (current_kboard, Vinput_decode_map)))
{
Lisp_Object msg = build_unibyte_string ("\f\nInput decoding map translations");
CALLN (Ffuncall,
Qhelp__describe_map_tree,
KVAR (current_kboard, Vinput_decode_map), Qnil, Qnil, prefix,
msg, nomenu, Qt, Qnil, Qnil, buffer);
}
return Qnil;
}