the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include "config.h"
+#include <config.h>
#include <stdio.h>
#undef NULL
#include "lisp.h"
"Args KEYMAP, KEY, DEF. Define key sequence KEY, in KEYMAP, as DEF.\n\
KEYMAP is a keymap. KEY is a string or a vector of symbols and characters\n\
meaning a sequence of keystrokes and events.\n\
+Non-ASCII characters with codes above 127 (such as ISO Latin-1)\n\
+can be included if you use a vector.\n\
DEF is anything that can be a key's definition:\n\
nil (means key is undefined in this keymap),\n\
a command (a Lisp function suitable for interactive calling)\n\
\n\
Normally, `key-binding' ignores bindings for t, which act as default\n\
bindings, used when nothing else in the keymap applies; this makes it\n\
-useable as a general function for probing keymaps. However, if the\n\
-third optional argument ACCEPT-DEFAULT is non-nil, `key-binding' will\n\
+usable as a general function for probing keymaps. However, if the\n\
+optional second argument ACCEPT-DEFAULT is non-nil, `key-binding' does\n\
recognize the default bindings, just as `read-key-sequence' does.")
(key, accept_default)
Lisp_Object key;
"Give KEY a global binding as COMMAND.\n\
COMMAND is a symbol naming an interactively-callable function.\n\
KEY is a key sequence (a string or vector of characters or event types).\n\
+Non-ASCII characters with codes above 127 (such as ISO Latin-1)\n\
+can be included if you use a vector.\n\
Note that if KEY has a local binding in the current buffer\n\
that local binding will continue to shadow any global binding.")
(keys, function)
"Give KEY a local binding as COMMAND.\n\
COMMAND is a symbol naming an interactively-callable function.\n\
KEY is a key sequence (a string or vector of characters or event types).\n\
+Non-ASCII characters with codes above 127 (such as ISO Latin-1)\n\
+can be included if you use a vector.\n\
The binding goes in the current buffer's local map,\n\
which is shared with other buffers in the same major mode.")
(keys, function)
"Find all keymaps accessible via prefix characters from KEYMAP.\n\
Returns a list of elements of the form (KEYS . MAP), where the sequence\n\
KEYS starting from KEYMAP gets you to MAP. These elements are ordered\n\
-so that the KEYS increase in length. The first element is (\"\" . KEYMAP).")
+so that the KEYS increase in length. The first element is (\"\" . KEYMAP).\n\
+An optional argument PREFIX, if non-nil, should be a key sequence;\n\
+then the value includes only maps for prefixes that start with PREFIX.")
(startmap, prefix)
Lisp_Object startmap, prefix;
{
descbuf = XCONS (arg)->car;
prefix = XCONS (arg)->cdr;
+ shadow = Qnil;
Fset_buffer (Vstandard_output);
{
int i, nmaps;
Lisp_Object *modes, *maps;
- Lisp_Object shadow;
-
- shadow = Qnil;
/* Temporarily switch to descbuf, so that we can get that buffer's
minor modes correctly. */
nmaps = current_minor_maps (&modes, &maps);
Fset_buffer (Vstandard_output);
- shadow = Qnil;
-
/* Print the minor mode maps. */
for (i = 0; i < nmaps; i++)
{
+ /* Tht title for a minor mode keymap
+ is constructed at run time.
+ We let describe_map_tree do the actual insertion
+ because it takes care of other features when doing so. */
+ char *title = (char *) alloca (40 + XSYMBOL (modes[i])->name->size);
+ char *p = title;
+
if (XTYPE (modes[i]) == Lisp_Symbol)
{
- insert_char ('`');
- insert_string (XSYMBOL (modes[i])->name->data);
- insert_char ('\'');
+ *p++ = '`';
+ bcopy (XSYMBOL (modes[i])->name->data, p,
+ XSYMBOL (modes[i])->name->size);
+ p += XSYMBOL (modes[i])->name->size;
+ *p++ = '\'';
}
else
- insert_string ("Strangely Named");
- insert_string (" Minor Mode Bindings:\n");
- describe_map_tree (maps[i], 0, shadow, prefix, 0);
+ {
+ bcopy ("Strangely Named", p, sizeof ("Strangely Named"));
+ p += sizeof ("Strangely Named");
+ }
+ bcopy (" Minor Mode Bindings", p, sizeof (" Minor Mode Bindings"));
+ p += sizeof (" Minor Mode Bindings");
+ *p = 0;
+
+ describe_map_tree (maps[i], 0, shadow, prefix, title);
shadow = Fcons (maps[i], shadow);
- insert_char ('\n');
}
}
if (!NILP (start1))
{
describe_map_tree (start1, 0, shadow, prefix,
- "Major Mode Bindings:\n");
+ "Major Mode Bindings");
shadow = Fcons (start1, shadow);
- insert_string ("\n");
}
describe_map_tree (current_global_map, 0, shadow, prefix,
- "Global Bindings:\n");
+ "Global Bindings");
Fset_buffer (descbuf);
return Qnil;
If SHADOW is non-nil, it is a list of maps;
don't mention keys which would be shadowed by any of them.
PREFIX, if non-nil, says mention only keys that start with PREFIX.
- TITLE, if not 0, is a string to insert at the beginning. */
+ TITLE, if not 0, is a string to insert at the beginning.
+ TITLE should not end with a colon or a newline; we supply that. */
void
describe_map_tree (startmap, partial, shadow, prefix, title)
{
Lisp_Object maps;
struct gcpro gcpro1;
+ int something = 0;
char *key_heading
= "\
key binding\n\
if (!NILP (maps))
{
if (title)
- insert_string (title);
+ {
+ insert_string (title);
+ if (!NILP (prefix))
+ {
+ insert_string (" Starting With ");
+ insert1 (Fkey_description (prefix));
+ }
+ insert_string (":\n");
+ }
insert_string (key_heading);
+ something = 1;
}
for (; !NILP (maps); maps = Fcdr (maps))
skip: ;
}
+ if (something)
+ insert_string ("\n");
+
UNGCPRO;
}
The read-key-sequence function replaces subsequences bound by\n\
function-key-map with their bindings. When the current local and global\n\
keymaps have no binding for the current key sequence but\n\
-function-key-map binds a suffix of the sequence to a vector,\n\
+function-key-map binds a suffix of the sequence to a vector or string,\n\
read-key-sequence replaces the matching suffix with its binding, and\n\
continues with the new sequence.\n\
\n\
-For example, suppose function-key-map binds `ESC O P' to [pf1].\n\
-Typing `ESC O P' to read-key-sequence would return [pf1]. Typing\n\
-`C-x ESC O P' would return [?\C-x pf1]. If [pf1] were a prefix\n\
-key, typing `ESC O P x' would return [pf1 x].");
+For example, suppose function-key-map binds `ESC O P' to [f1].\n\
+Typing `ESC O P' to read-key-sequence would return [f1]. Typing\n\
+`C-x ESC O P' would return [?\\C-x f1]. If [f1] were a prefix\n\
+key, typing `ESC O P x' would return [f1 x].");
Vfunction_key_map = Fmake_sparse_keymap (Qnil);
Qsingle_key_description = intern ("single-key-description");