X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/9898bd0e5b0e51ce9040e11ae25c9a07ec08eb4f..9730daca4425e2014ff43a3b1b205b598e63c72a:/src/keymap.c diff --git a/src/keymap.c b/src/keymap.c index 2a0f162a0e..510c5ea7f3 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -1,5 +1,5 @@ /* Manipulation of keymaps - Copyright (C) 1985-1988, 1993-1995, 1998-2011 Free Software Foundation, Inc. + Copyright (C) 1985-1988, 1993-1995, 1998-2012 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -43,8 +43,8 @@ along with GNU Emacs. If not, see . */ #include #include "lisp.h" #include "commands.h" -#include "buffer.h" #include "character.h" +#include "buffer.h" #include "charset.h" #include "keyboard.h" #include "frame.h" @@ -92,7 +92,6 @@ static Lisp_Object where_is_cache; /* Which keymaps are reverse-stored in the cache. */ static Lisp_Object where_is_cache_keymaps; -static Lisp_Object Flookup_key (Lisp_Object, Lisp_Object, Lisp_Object); static Lisp_Object store_in_keymap (Lisp_Object, Lisp_Object, Lisp_Object); static Lisp_Object define_as_prefix (Lisp_Object, Lisp_Object); @@ -956,8 +955,6 @@ store_in_keymap (Lisp_Object keymap, register Lisp_Object idx, Lisp_Object def) return def; } -static Lisp_Object Fcopy_keymap (Lisp_Object); - static Lisp_Object copy_keymap_item (Lisp_Object elt) { @@ -1481,7 +1478,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) /* Use malloc here. See the comment above this function. Avoid realloc here; it causes spurious traps on GNU/Linux [KFS] */ BLOCK_INPUT; - newmodes = (Lisp_Object *) malloc (allocsize); + newmodes = malloc (allocsize); if (newmodes) { if (cmm_modes) @@ -1493,7 +1490,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) cmm_modes = newmodes; } - newmaps = (Lisp_Object *) malloc (allocsize); + newmaps = malloc (allocsize); if (newmaps) { if (cmm_maps) @@ -2013,9 +2010,7 @@ then the value includes only maps for prefixes that start with PREFIX. */) return Qnil; } else - maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil), - get_keymap (keymap, 1, 0)), - Qnil); + maps = Fcons (Fcons (zero_vector, get_keymap (keymap, 1, 0)), Qnil); /* For each map in the list maps, look at any other maps it points to, @@ -2053,8 +2048,9 @@ static Lisp_Object Qsingle_key_description, Qkey_description; DEFUN ("key-description", Fkey_description, Skey_description, 1, 2, 0, doc: /* Return a pretty description of key-sequence KEYS. Optional arg PREFIX is the sequence of keys leading up to KEYS. -Control characters turn into "C-foo" sequences, meta into "M-foo", -spaces are put between sequence elements, etc. */) +For example, [?\C-x ?l] is converted into the string \"C-x l\". + +The `kbd' macro is an approximate inverse of this. */) (Lisp_Object keys, Lisp_Object prefix) { ptrdiff_t len = 0; @@ -2288,9 +2284,15 @@ around function keys and event symbols. */) if (CONSP (key) && lucid_event_type_list_p (key)) key = Fevent_convert_list (key); + if (CONSP (key) && INTEGERP (XCAR (key)) && INTEGERP (XCDR (key))) + /* An interval from a map-char-table. */ + return concat3 (Fsingle_key_description (XCAR (key), no_angles), + build_string (".."), + Fsingle_key_description (XCDR (key), no_angles)); + key = EVENT_HEAD (key); - if (INTEGERP (key)) /* Normal character */ + if (INTEGERP (key)) /* Normal character. */ { char tem[KEY_DESCRIPTION_SIZE], *p; @@ -2298,7 +2300,7 @@ around function keys and event symbols. */) *p = 0; return make_specified_string (tem, -1, p - tem, 1); } - else if (SYMBOLP (key)) /* Function key or event-symbol */ + else if (SYMBOLP (key)) /* Function key or event-symbol. */ { if (NILP (no_angles)) { @@ -2564,7 +2566,8 @@ where_is_internal (Lisp_Object definition, Lisp_Object keymaps, DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 5, 0, doc: /* Return list of keys that invoke DEFINITION. If KEYMAP is a keymap, search only KEYMAP and the global keymap. -If KEYMAP is nil, search all the currently active keymaps. +If KEYMAP is nil, search all the currently active keymaps, except + for `overriding-local-map' (which is ignored). If KEYMAP is a list of keymaps, search only those keymaps. If optional 3rd arg FIRSTONLY is non-nil, return the first key sequence found, @@ -2579,9 +2582,17 @@ If optional 4th arg NOINDIRECT is non-nil, don't follow indirections to other keymaps or slots. This makes it possible to search for an indirect definition itself. -If optional 5th arg NO-REMAP is non-nil, don't search for key sequences -that invoke a command which is remapped to DEFINITION, but include the -remapped command in the returned list. */) +The optional 5th arg NO-REMAP alters how command remapping is handled: + +- If another command OTHER-COMMAND is remapped to DEFINITION, normally + search for the bindings of OTHER-COMMAND and include them in the + returned list. But if NO-REMAP is non-nil, include the vector + [remap OTHER-COMMAND] in the returned list instead, without + searching for those other bindings. + +- If DEFINITION is remapped to OTHER-COMMAND, normally return the + bindings for OTHER-COMMAND. But if NO-REMAP is non-nil, return the + bindings for DEFINITION instead, ignoring its remapping. */) (Lisp_Object definition, Lisp_Object keymap, Lisp_Object firstonly, Lisp_Object noindirect, Lisp_Object no_remap) { /* The keymaps in which to search. */ @@ -2910,7 +2921,7 @@ You type Translation\n\ if (!SYMBOLP (modes[i])) abort (); - p = title = (char *) alloca (42 + SCHARS (SYMBOL_NAME (modes[i]))); + p = title = alloca (42 + SCHARS (SYMBOL_NAME (modes[i]))); *p++ = '\f'; *p++ = '\n'; *p++ = '`'; @@ -2980,9 +2991,9 @@ You type Translation\n\ If MENTION_SHADOW is nonzero, then when something is shadowed by SHADOW, don't omit it; instead, mention it but say it is shadowed. - Return whether something was inserted or not. */ + Any inserted text ends in two newlines (used by `help-make-xrefs'). */ -int +void describe_map_tree (Lisp_Object startmap, int partial, Lisp_Object shadow, Lisp_Object prefix, const char *title, int nomenu, int transl, int always_title, int mention_shadow) @@ -3092,8 +3103,10 @@ key binding\n\ skip: ; } + if (something) + insert_string ("\n"); + UNGCPRO; - return something; } static int previous_description_column; @@ -3690,11 +3703,11 @@ syms_of_keymap (void) Ffset (intern_c_string ("Control-X-prefix"), control_x_map); exclude_keys - = pure_cons (pure_cons (make_pure_c_string ("DEL"), make_pure_c_string ("\\d")), - pure_cons (pure_cons (make_pure_c_string ("TAB"), make_pure_c_string ("\\t")), - pure_cons (pure_cons (make_pure_c_string ("RET"), make_pure_c_string ("\\r")), - pure_cons (pure_cons (make_pure_c_string ("ESC"), make_pure_c_string ("\\e")), - pure_cons (pure_cons (make_pure_c_string ("SPC"), make_pure_c_string (" ")), + = pure_cons (pure_cons (build_pure_c_string ("DEL"), build_pure_c_string ("\\d")), + pure_cons (pure_cons (build_pure_c_string ("TAB"), build_pure_c_string ("\\t")), + pure_cons (pure_cons (build_pure_c_string ("RET"), build_pure_c_string ("\\r")), + pure_cons (pure_cons (build_pure_c_string ("ESC"), build_pure_c_string ("\\e")), + pure_cons (pure_cons (build_pure_c_string ("SPC"), build_pure_c_string (" ")), Qnil))))); staticpro (&exclude_keys);