X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/b9b1c01690ef9e061dfa2a2c37ca4e7892a1172a..5f85994ad17fbe952504bfafb49fbef4ded186af:/src/keymap.c diff --git a/src/keymap.c b/src/keymap.c index 5177ccfbf8..2977b4dec0 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -1,6 +1,6 @@ /* Manipulation of keymaps - Copyright (C) 1985, 86,87,88,93,94,95,98,99, 2000, 01, 2004 - Free Software Foundation, Inc. + Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1998, 1999, 2000, + 2001, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -214,13 +214,13 @@ when reading a key-sequence to be looked-up in this keymap. */) (map) Lisp_Object map; { + map = get_keymap (map, 0, 0); while (CONSP (map)) { - register Lisp_Object tem; - tem = Fcar (map); + Lisp_Object tem = XCAR (map); if (STRINGP (tem)) return tem; - map = Fcdr (map); + map = XCDR (map); } return Qnil; } @@ -268,7 +268,8 @@ get_keymap (object, error, autoload) /* Should we do an autoload? Autoload forms for keymaps have Qkeymap as their fifth element. */ - if ((autoload || !error) && EQ (XCAR (tem), Qautoload)) + if ((autoload || !error) && EQ (XCAR (tem), Qautoload) + && SYMBOLP (object)) { Lisp_Object tail; @@ -524,6 +525,10 @@ access_keymap (map, idx, t_ok, noinherit, autoload) struct gcpro gcpro1; Lisp_Object meta_map; GCPRO1 (map); + /* A strange value in which Meta is set would cause + infinite recursion. Protect against that. */ + if (XINT (meta_prefix_char) & CHAR_META) + meta_prefix_char = make_number (27); meta_map = get_keymap (access_keymap (map, meta_prefix_char, t_ok, noinherit, autoload), 0, autoload); @@ -702,19 +707,23 @@ map_keymap_call (key, val, fun, dummy) call2 (fun, key, val); } -DEFUN ("map-keymap", Fmap_keymap, Smap_keymap, 2, 2, 0, +DEFUN ("map-keymap", Fmap_keymap, Smap_keymap, 2, 3, 0, doc: /* Call FUNCTION for every binding in KEYMAP. FUNCTION is called with two arguments: the event and its binding. If KEYMAP has a parent, the parent's bindings are included as well. This works recursively: if the parent has itself a parent, then the -grandparent's bindings are also included and so on. */) - (function, keymap) - Lisp_Object function, keymap; +grandparent's bindings are also included and so on. +usage: (map-keymap FUNCTION KEYMAP) */) + (function, keymap, sort_first) + Lisp_Object function, keymap, sort_first; { if (INTEGERP (function)) /* We have to stop integers early since map_keymap gives them special significance. */ Fsignal (Qinvalid_function, Fcons (function, Qnil)); + if (! NILP (sort_first)) + return call3 (intern ("map-keymap-internal"), function, keymap, Qt); + map_keymap (keymap, map_keymap_call, function, NULL, 1); return Qnil; } @@ -1268,7 +1277,7 @@ recognize the default bindings, just as `read-key-sequence' does. */) c = Fevent_convert_list (c); /* Turn the 8th bit of string chars into a meta modifier. */ - if (XINT (c) & 0x80 && STRINGP (key)) + if (INTEGERP (c) && XINT (c) & 0x80 && STRINGP (key)) XSETINT (c, (XINT (c) | meta_modifier) & ~0x80); /* Allow string since binding for `menu-bar-select-buffer' @@ -1514,10 +1523,13 @@ OLP if non-nil indicates that we should obey `overriding-local-map' and if (!NILP (olp)) { - if (!NILP (Voverriding_local_map)) - keymaps = Fcons (Voverriding_local_map, keymaps); if (!NILP (current_kboard->Voverriding_terminal_local_map)) keymaps = Fcons (current_kboard->Voverriding_terminal_local_map, keymaps); + /* The doc said that overriding-terminal-local-map should + override overriding-local-map. The code used them both, + but it seems clearer to use just one. rms, jan 2005. */ + else if (!NILP (Voverriding_local_map)) + keymaps = Fcons (Voverriding_local_map, keymaps); } if (NILP (XCDR (keymaps))) { @@ -1525,16 +1537,20 @@ OLP if non-nil indicates that we should obey `overriding-local-map' and Lisp_Object *maps; int nmaps, i; + /* This usually returns the buffer's local map, + but that can be overridden by a `local-map' property. */ local = get_local_map (PT, current_buffer, Qlocal_map); if (!NILP (local)) keymaps = Fcons (local, keymaps); + /* Now put all the minor mode keymaps on the list. */ nmaps = current_minor_maps (0, &maps); for (i = --nmaps; i >= 0; i--) if (!NILP (maps[i])) keymaps = Fcons (maps[i], keymaps); + /* This returns nil unless there is a `keymap' property. */ local = get_local_map (PT, current_buffer, Qkeymap); if (!NILP (local)) keymaps = Fcons (local, keymaps);