diff options
Diffstat (limited to 'src/keymap.c')
| -rw-r--r-- | src/keymap.c | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/src/keymap.c b/src/keymap.c index 0aaf9373ba1..a5d50b7fbf1 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -1217,23 +1217,42 @@ binding KEY to DEF is added at the front of KEYMAP. */) | |||
| 1217 | 1217 | ||
| 1218 | /* This function may GC (it calls Fkey_binding). */ | 1218 | /* This function may GC (it calls Fkey_binding). */ |
| 1219 | 1219 | ||
| 1220 | DEFUN ("command-remapping", Fcommand_remapping, Scommand_remapping, 1, 2, 0, | 1220 | DEFUN ("command-remapping", Fcommand_remapping, Scommand_remapping, 1, 3, 0, |
| 1221 | doc: /* Return the remapping for command COMMAND in current keymaps. | 1221 | doc: /* Return the remapping for command COMMAND. |
| 1222 | Returns nil if COMMAND is not remapped (or not a symbol). | 1222 | Returns nil if COMMAND is not remapped (or not a symbol). |
| 1223 | 1223 | ||
| 1224 | If the optional argument POSITION is non-nil, it specifies a mouse | 1224 | If the optional argument POSITION is non-nil, it specifies a mouse |
| 1225 | position as returned by `event-start' and `event-end', and the | 1225 | position as returned by `event-start' and `event-end', and the |
| 1226 | remapping occurs in the keymaps associated with it. It can also be a | 1226 | remapping occurs in the keymaps associated with it. It can also be a |
| 1227 | number or marker, in which case the keymap properties at the specified | 1227 | number or marker, in which case the keymap properties at the specified |
| 1228 | buffer position instead of point are used. */) | 1228 | buffer position instead of point are used. The KEYMAPS argument is |
| 1229 | (command, position) | 1229 | ignored if POSITION is non-nil. |
| 1230 | Lisp_Object command, position; | 1230 | |
| 1231 | If the optional argument KEYMAPS is non-nil, it should be a list of | ||
| 1232 | keymaps to search for command remapping. Otherwise, search for the | ||
| 1233 | remapping in all currently active keymaps. */) | ||
| 1234 | (command, position, keymaps) | ||
| 1235 | Lisp_Object command, position, keymaps; | ||
| 1231 | { | 1236 | { |
| 1232 | if (!SYMBOLP (command)) | 1237 | if (!SYMBOLP (command)) |
| 1233 | return Qnil; | 1238 | return Qnil; |
| 1234 | 1239 | ||
| 1235 | ASET (command_remapping_vector, 1, command); | 1240 | ASET (command_remapping_vector, 1, command); |
| 1236 | return Fkey_binding (command_remapping_vector, Qnil, Qt, position); | 1241 | |
| 1242 | if (NILP (keymaps)) | ||
| 1243 | return Fkey_binding (command_remapping_vector, Qnil, Qt, position); | ||
| 1244 | else | ||
| 1245 | { | ||
| 1246 | Lisp_Object maps, binding; | ||
| 1247 | |||
| 1248 | for (maps = keymaps; !NILP (maps); maps = Fcdr (maps)) | ||
| 1249 | { | ||
| 1250 | binding = Flookup_key (Fcar (maps), command_remapping_vector, Qnil); | ||
| 1251 | if (!NILP (binding) && !INTEGERP (binding)) | ||
| 1252 | return binding; | ||
| 1253 | } | ||
| 1254 | return Qnil; | ||
| 1255 | } | ||
| 1237 | } | 1256 | } |
| 1238 | 1257 | ||
| 1239 | /* Value is number if KEY is too long; nil if valid but has no definition. */ | 1258 | /* Value is number if KEY is too long; nil if valid but has no definition. */ |
| @@ -1394,8 +1413,10 @@ silly_event_symbol_error (c) | |||
| 1394 | static Lisp_Object *cmm_modes = NULL, *cmm_maps = NULL; | 1413 | static Lisp_Object *cmm_modes = NULL, *cmm_maps = NULL; |
| 1395 | static int cmm_size = 0; | 1414 | static int cmm_size = 0; |
| 1396 | 1415 | ||
| 1397 | /* Store a pointer to an array of the keymaps of the currently active | 1416 | /* Store a pointer to an array of the currently active minor modes in |
| 1398 | minor modes in *buf, and return the number of maps it contains. | 1417 | *modeptr, a pointer to an array of the keymaps of the currently |
| 1418 | active minor modes in *mapptr, and return the number of maps | ||
| 1419 | *mapptr contains. | ||
| 1399 | 1420 | ||
| 1400 | This function always returns a pointer to the same buffer, and may | 1421 | This function always returns a pointer to the same buffer, and may |
| 1401 | free or reallocate it, so if you want to keep it for a long time or | 1422 | free or reallocate it, so if you want to keep it for a long time or |
| @@ -1761,7 +1782,7 @@ specified buffer position instead of point are used. | |||
| 1761 | if (NILP (no_remap) && SYMBOLP (value)) | 1782 | if (NILP (no_remap) && SYMBOLP (value)) |
| 1762 | { | 1783 | { |
| 1763 | Lisp_Object value1; | 1784 | Lisp_Object value1; |
| 1764 | if (value1 = Fcommand_remapping (value, position), !NILP (value1)) | 1785 | if (value1 = Fcommand_remapping (value, position, Qnil), !NILP (value1)) |
| 1765 | value = value1; | 1786 | value = value1; |
| 1766 | } | 1787 | } |
| 1767 | 1788 | ||
| @@ -2570,15 +2591,6 @@ where_is_internal (definition, keymaps, firstonly, noindirect, no_remap) | |||
| 2570 | /* 1 means ignore all menu bindings entirely. */ | 2591 | /* 1 means ignore all menu bindings entirely. */ |
| 2571 | int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); | 2592 | int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); |
| 2572 | 2593 | ||
| 2573 | /* If this command is remapped, then it has no key bindings | ||
| 2574 | of its own. */ | ||
| 2575 | if (NILP (no_remap) && SYMBOLP (definition)) | ||
| 2576 | { | ||
| 2577 | Lisp_Object tem; | ||
| 2578 | if (tem = Fcommand_remapping (definition, Qnil), !NILP (tem)) | ||
| 2579 | return Qnil; | ||
| 2580 | } | ||
| 2581 | |||
| 2582 | found = keymaps; | 2594 | found = keymaps; |
| 2583 | while (CONSP (found)) | 2595 | while (CONSP (found)) |
| 2584 | { | 2596 | { |
| @@ -2592,6 +2604,13 @@ where_is_internal (definition, keymaps, firstonly, noindirect, no_remap) | |||
| 2592 | found = Qnil; | 2604 | found = Qnil; |
| 2593 | sequences = Qnil; | 2605 | sequences = Qnil; |
| 2594 | 2606 | ||
| 2607 | /* If this command is remapped, then it has no key bindings | ||
| 2608 | of its own. */ | ||
| 2609 | if (NILP (no_remap) | ||
| 2610 | && SYMBOLP (definition) | ||
| 2611 | && !NILP (Fcommand_remapping (definition, Qnil, keymaps))) | ||
| 2612 | RETURN_UNGCPRO (Qnil); | ||
| 2613 | |||
| 2595 | for (; !NILP (maps); maps = Fcdr (maps)) | 2614 | for (; !NILP (maps); maps = Fcdr (maps)) |
| 2596 | { | 2615 | { |
| 2597 | /* Key sequence to reach map, and the map that it reaches */ | 2616 | /* Key sequence to reach map, and the map that it reaches */ |