Mercurial > emacs
comparison src/keymap.c @ 76887:a5751af0b8a7
(Fcommand_remapping): New optional argument.
(where_is_internal): Use new keymaps argument.
(Fkey_binding): Caller changed.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 01 Apr 2007 22:03:22 +0000 |
parents | 4f957abd4298 |
children | 6698eef48043 dc002877ce12 4ef881a120fe |
comparison
equal
deleted
inserted
replaced
76886:da21c991a6d5 | 76887:a5751af0b8a7 |
---|---|
1222 } | 1222 } |
1223 } | 1223 } |
1224 | 1224 |
1225 /* This function may GC (it calls Fkey_binding). */ | 1225 /* This function may GC (it calls Fkey_binding). */ |
1226 | 1226 |
1227 DEFUN ("command-remapping", Fcommand_remapping, Scommand_remapping, 1, 2, 0, | 1227 DEFUN ("command-remapping", Fcommand_remapping, Scommand_remapping, 1, 3, 0, |
1228 doc: /* Return the remapping for command COMMAND in current keymaps. | 1228 doc: /* Return the remapping for command COMMAND. |
1229 Returns nil if COMMAND is not remapped (or not a symbol). | 1229 Returns nil if COMMAND is not remapped (or not a symbol). |
1230 | 1230 |
1231 If the optional argument POSITION is non-nil, it specifies a mouse | 1231 If the optional argument POSITION is non-nil, it specifies a mouse |
1232 position as returned by `event-start' and `event-end', and the | 1232 position as returned by `event-start' and `event-end', and the |
1233 remapping occurs in the keymaps associated with it. It can also be a | 1233 remapping occurs in the keymaps associated with it. It can also be a |
1234 number or marker, in which case the keymap properties at the specified | 1234 number or marker, in which case the keymap properties at the specified |
1235 buffer position instead of point are used. */) | 1235 buffer position instead of point are used. The KEYMAPS argument is |
1236 (command, position) | 1236 ignored if POSITION is non-nil. |
1237 Lisp_Object command, position; | 1237 |
1238 If the optional argument KEYMAPS is non-nil, it should be a list of | |
1239 keymaps to search for command remapping. Otherwise, search for the | |
1240 remapping in all currently active keymaps. */) | |
1241 (command, position, keymaps) | |
1242 Lisp_Object command, position, keymaps; | |
1238 { | 1243 { |
1239 if (!SYMBOLP (command)) | 1244 if (!SYMBOLP (command)) |
1240 return Qnil; | 1245 return Qnil; |
1241 | 1246 |
1242 ASET (command_remapping_vector, 1, command); | 1247 ASET (command_remapping_vector, 1, command); |
1243 return Fkey_binding (command_remapping_vector, Qnil, Qt, position); | 1248 |
1249 if (NILP (keymaps)) | |
1250 return Fkey_binding (command_remapping_vector, Qnil, Qt, position); | |
1251 else | |
1252 { | |
1253 Lisp_Object maps, binding; | |
1254 | |
1255 for (maps = keymaps; !NILP (maps); maps = Fcdr (maps)) | |
1256 { | |
1257 binding = Flookup_key (Fcar (maps), command_remapping_vector, Qnil); | |
1258 if (!NILP (binding) && !INTEGERP (binding)) | |
1259 return binding; | |
1260 } | |
1261 return Qnil; | |
1262 } | |
1244 } | 1263 } |
1245 | 1264 |
1246 /* Value is number if KEY is too long; nil if valid but has no definition. */ | 1265 /* Value is number if KEY is too long; nil if valid but has no definition. */ |
1247 /* GC is possible in this function if it autoloads a keymap. */ | 1266 /* GC is possible in this function if it autoloads a keymap. */ |
1248 | 1267 |
1768 command, look for a key binding (ie. remapping) for that command. */ | 1787 command, look for a key binding (ie. remapping) for that command. */ |
1769 | 1788 |
1770 if (NILP (no_remap) && SYMBOLP (value)) | 1789 if (NILP (no_remap) && SYMBOLP (value)) |
1771 { | 1790 { |
1772 Lisp_Object value1; | 1791 Lisp_Object value1; |
1773 if (value1 = Fcommand_remapping (value, position), !NILP (value1)) | 1792 if (value1 = Fcommand_remapping (value, position, Qnil), !NILP (value1)) |
1774 value = value1; | 1793 value = value1; |
1775 } | 1794 } |
1776 | 1795 |
1777 return value; | 1796 return value; |
1778 } | 1797 } |
2592 found = Qnil; | 2611 found = Qnil; |
2593 sequences = Qnil; | 2612 sequences = Qnil; |
2594 | 2613 |
2595 /* If this command is remapped, then it has no key bindings | 2614 /* If this command is remapped, then it has no key bindings |
2596 of its own. */ | 2615 of its own. */ |
2597 if (NILP (no_remap) && SYMBOLP (definition)) | 2616 if (NILP (no_remap) |
2598 { | 2617 && SYMBOLP (definition) |
2599 Lisp_Object kmaps, map, remap; | 2618 && !NILP (Fcommand_remapping (definition, Qnil, keymaps))) |
2600 | 2619 RETURN_UNGCPRO (Qnil); |
2601 for (kmaps = maps; !NILP (kmaps); kmaps = Fcdr (kmaps)) | |
2602 if (map = Fcdr (Fcar (kmaps)), KEYMAPP (map)) | |
2603 { | |
2604 ASET (command_remapping_vector, 1, definition); | |
2605 remap = Flookup_key (map, command_remapping_vector, Qnil); | |
2606 if (!NILP (remap) && !INTEGERP (remap)) | |
2607 RETURN_UNGCPRO (Qnil); | |
2608 } | |
2609 } | |
2610 | 2620 |
2611 for (; !NILP (maps); maps = Fcdr (maps)) | 2621 for (; !NILP (maps); maps = Fcdr (maps)) |
2612 { | 2622 { |
2613 /* Key sequence to reach map, and the map that it reaches */ | 2623 /* Key sequence to reach map, and the map that it reaches */ |
2614 register Lisp_Object this, map, tem; | 2624 register Lisp_Object this, map, tem; |