X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fkeymap.c;h=3752f0f06e73f3cd49c20efb9a8f29aa8860943d;hb=4f9f80ecf7b7c7a9dd3ee4c988813f28291825d3;hp=4aa26f761e963e9e37dd59428824c02440dafac2;hpb=40402600969429d5253e62c6314a3eebbb21f027;p=chise%2Fxemacs-chise.git.1 diff --git a/src/keymap.c b/src/keymap.c index 4aa26f7..3752f0f 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -472,7 +472,7 @@ keymap_lookup_directly (Lisp_Object keymap, if ((modifiers & ~(XEMACS_MOD_CONTROL | XEMACS_MOD_META | XEMACS_MOD_SUPER | XEMACS_MOD_HYPER | XEMACS_MOD_ALT | XEMACS_MOD_SHIFT)) != 0) - abort (); + ABORT (); k = XKEYMAP (keymap); @@ -547,7 +547,7 @@ keymap_delete_inverse_internal (Lisp_Object inverse_table, Lisp_Object *prev; if (UNBOUNDP (keys)) - abort (); + ABORT (); for (prev = &new_keys, tail = new_keys; ; @@ -1015,10 +1015,8 @@ get_keymap (Lisp_Object object, int errorp, int autoload) && EQ (XCAR (tem), Qautoload) && EQ (Fcar (Fcdr (Fcdr (Fcdr (Fcdr (tem))))), Qkeymap)) { - struct gcpro gcpro1, gcpro2; - GCPRO2 (tem, object); + /* do_autoload GCPROs both arguments */ do_autoload (tem, object); - UNGCPRO; } else if (errorp) object = wrong_type_argument (Qkeymapp, object); @@ -1649,7 +1647,7 @@ define_key_alternate_name (struct key_data *key, returned_value->modifiers = 0; if (modifiers_sans_meta == XEMACS_MOD_CONTROL) { - if EQ (keysym, QKspace) + if (EQ (keysym, QKspace)) MACROLET (make_char ('@'), modifiers); else if (!CHARP (keysym)) return; @@ -1721,7 +1719,7 @@ ensure_meta_prefix_char_keymapp (Lisp_Object keys, int indx, else { new_keys = Qnil; - abort (); + ABORT (); } if (EQ (keys, new_keys)) @@ -2990,7 +2988,8 @@ faster. (function, keymap, sort_first)) { /* This function can GC */ - struct gcpro gcpro1, gcpro2; + struct gcpro gcpro1, gcpro2, gcpro3; + Lisp_Object table = Qnil; /* tolerate obviously transposed args */ if (!NILP (Fkeymapp (function))) @@ -2999,9 +2998,17 @@ faster. function = keymap; keymap = tmp; } - GCPRO2 (function, keymap); + + GCPRO3 (function, keymap, table); keymap = get_keymap (keymap, 1, 1); - map_keymap (XKEYMAP (keymap)->table, !NILP (sort_first), + + /* elisp_maphash does not allow mapping functions to modify the hash + table being mapped over. Since map-keymap explicitly allows a + mapping function to modify KEYMAP, we map over a copy of the hash + table instead. */ + table = Fcopy_hash_table (XKEYMAP (keymap)->table); + + map_keymap (table, !NILP (sort_first), map_keymap_mapper, LISP_TO_VOID (function)); UNGCPRO; return Qnil; @@ -3053,10 +3060,10 @@ accessible_keymaps_mapper_1 (Lisp_Object keysym, Lisp_Object contents, key.modifiers = modifiers; if (NILP (cmd)) - abort (); + ABORT (); cmd = get_keymap (cmd, 0, 1); if (!KEYMAPP (cmd)) - abort (); + ABORT (); vec = make_vector (XVECTOR_LENGTH (thisseq) + 1, Qnil); len = XVECTOR_LENGTH (thisseq); @@ -3582,7 +3589,7 @@ where_is_recursive_mapper (Lisp_Object map, void *arg) /* OK, the key is for real */ if (target_buffer) { - if (!firstonly) abort (); + if (!firstonly) ABORT (); format_raw_keys (so_far, keys_count + 1, target_buffer); return make_int (1); } @@ -3656,6 +3663,8 @@ where_is_recursive_mapper (Lisp_Object map, void *arg) struct key_data *new = xnew_array (struct key_data, size); memcpy ((void *)new, (const void *)c->keys_so_far, c->keys_so_far_total_size * sizeof (struct key_data)); + xfree (c->keys_so_far); + c->keys_so_far = new; } else XREALLOC_ARRAY (c->keys_so_far, struct key_data, size); @@ -4345,8 +4354,28 @@ You should *bind* this, not set it. DEFVAR_LISP ("key-translation-map", &Vkey_translation_map /* Keymap of key translations that can override keymaps. -This keymap works like `function-key-map', but comes after that, + +This keymap works like `function-key-map', but is searched before it, and applies even for keys that have ordinary bindings. + +The `read-key-sequence' function replaces any subsequence bound by +`key-translation-map' with its binding. More precisely, when the active +keymaps have no binding for the current key sequence but +`key-translation-map' binds a suffix of the sequence to a vector or string, +`read-key-sequence' replaces the matching suffix with its binding, and +continues with the new sequence. See `key-binding' for details. + +The events that come from bindings in `key-translation-map' are not +themselves looked up in `key-translation-map'. + +#### FIXME: stolen from `function-key-map'; need better example. +#### I guess you could implement a Dvorak keyboard with this? +For example, suppose `key-translation-map' binds `ESC O P' to [f1]. +Typing `ESC O P' to `read-key-sequence' would return +\[#]. Typing `C-x ESC O P' would return +\[# #]. If [f1] +were a prefix key, typing `ESC O P x' would return +\[# #]. */ ); Vkey_translation_map = Qnil;