diff options
| author | Stefan Monnier | 2001-10-08 09:47:10 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2001-10-08 09:47:10 +0000 |
| commit | 54cbc3d4cd6541d32c02f0f5bc4decd637e2ed50 (patch) | |
| tree | a16e47559658577c92fa5edaef9a907279af4e15 | |
| parent | 3ecd9cc373e093b541ec10283ba83fe6dae58c14 (diff) | |
| download | emacs-54cbc3d4cd6541d32c02f0f5bc4decd637e2ed50.tar.gz emacs-54cbc3d4cd6541d32c02f0f5bc4decd637e2ed50.zip | |
(Fkeymap_prompt, Fcurrent_active_maps): New funs.
(accessible_keymaps_1): New function.
(Faccessible_keymaps, accessible_keymaps_char_table): Use it.
(Fwhere_is_internal): Use Fcurrent_active_maps.
(Fdescribe_buffer_bindings): Renamed from describe_buffer_bindings.
Insert in current buffer rather than standard-output.
Don't call `help-mode'. Export to elisp.
(describe_buffer_bindings): New wrapper.
(syms_of_keymap): Defsubr Skeymap_prompt, Scurrent_active_maps
and Sdescribe_buffer_bindings.
| -rw-r--r-- | src/keymap.c | 352 |
1 files changed, 175 insertions, 177 deletions
diff --git a/src/keymap.c b/src/keymap.c index 8f4a1cc478a..ac2727a623e 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -190,6 +190,24 @@ is also allowed as an element.") | |||
| 190 | return (KEYMAPP (object) ? Qt : Qnil); | 190 | return (KEYMAPP (object) ? Qt : Qnil); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | DEFUN ("keymap-prompt", Fkeymap_prompt, Skeymap_prompt, 1, 1, 0, | ||
| 194 | "Return the prompt-string of a keymap MAP.\n\ | ||
| 195 | If non-nil, the prompt is shown in the echo-area\n\ | ||
| 196 | when reading a key-sequence to be looked-up in this keymap.") | ||
| 197 | (map) | ||
| 198 | Lisp_Object map; | ||
| 199 | { | ||
| 200 | while (CONSP (map)) | ||
| 201 | { | ||
| 202 | register Lisp_Object tem; | ||
| 203 | tem = Fcar (map); | ||
| 204 | if (STRINGP (tem)) | ||
| 205 | return tem; | ||
| 206 | map = Fcdr (map); | ||
| 207 | } | ||
| 208 | return Qnil; | ||
| 209 | } | ||
| 210 | |||
| 193 | /* Check that OBJECT is a keymap (after dereferencing through any | 211 | /* Check that OBJECT is a keymap (after dereferencing through any |
| 194 | symbols). If it is, return it. | 212 | symbols). If it is, return it. |
| 195 | 213 | ||
| @@ -338,7 +356,7 @@ PARENT should be nil or another keymap.") | |||
| 338 | list = XCDR (prev); | 356 | list = XCDR (prev); |
| 339 | /* If there is a parent keymap here, replace it. | 357 | /* If there is a parent keymap here, replace it. |
| 340 | If we came to the end, add the parent in PREV. */ | 358 | If we came to the end, add the parent in PREV. */ |
| 341 | if (! CONSP (list) || KEYMAPP (list)) | 359 | if (!CONSP (list) || KEYMAPP (list)) |
| 342 | { | 360 | { |
| 343 | /* If we already have the right parent, return now | 361 | /* If we already have the right parent, return now |
| 344 | so that we avoid the loops below. */ | 362 | so that we avoid the loops below. */ |
| @@ -699,7 +717,7 @@ store_in_keymap (keymap, idx, def) | |||
| 699 | && (EQ (XCAR (def), Qmenu_item) || STRINGP (XCAR (def)))) | 717 | && (EQ (XCAR (def), Qmenu_item) || STRINGP (XCAR (def)))) |
| 700 | def = Fcons (XCAR (def), XCDR (def)); | 718 | def = Fcons (XCAR (def), XCDR (def)); |
| 701 | 719 | ||
| 702 | if (!CONSP (keymap) || ! EQ (XCAR (keymap), Qkeymap)) | 720 | if (!CONSP (keymap) || !EQ (XCAR (keymap), Qkeymap)) |
| 703 | error ("attempt to define a key in a non-keymap"); | 721 | error ("attempt to define a key in a non-keymap"); |
| 704 | 722 | ||
| 705 | /* If idx is a list (some sort of mouse click, perhaps?), | 723 | /* If idx is a list (some sort of mouse click, perhaps?), |
| @@ -804,6 +822,9 @@ is not copied.") | |||
| 804 | (keymap) | 822 | (keymap) |
| 805 | Lisp_Object keymap; | 823 | Lisp_Object keymap; |
| 806 | { | 824 | { |
| 825 | /* FIXME: This doesn't properly copy menu-items in vectors. */ | ||
| 826 | /* FIXME: This also copies the parent keymap. */ | ||
| 827 | |||
| 807 | register Lisp_Object copy, tail; | 828 | register Lisp_Object copy, tail; |
| 808 | 829 | ||
| 809 | copy = Fcopy_alist (get_keymap (keymap, 1, 0)); | 830 | copy = Fcopy_alist (get_keymap (keymap, 1, 0)); |
| @@ -990,7 +1011,7 @@ the front of KEYMAP.") | |||
| 990 | idx++; | 1011 | idx++; |
| 991 | } | 1012 | } |
| 992 | 1013 | ||
| 993 | if (! INTEGERP (c) && ! SYMBOLP (c) && ! CONSP (c)) | 1014 | if (!INTEGERP (c) && !SYMBOLP (c) && !CONSP (c)) |
| 994 | error ("Key sequence contains invalid events"); | 1015 | error ("Key sequence contains invalid events"); |
| 995 | 1016 | ||
| 996 | if (idx == length) | 1017 | if (idx == length) |
| @@ -1038,7 +1059,7 @@ recognize the default bindings, just as `read-key-sequence' does.") | |||
| 1038 | register Lisp_Object cmd; | 1059 | register Lisp_Object cmd; |
| 1039 | register Lisp_Object c; | 1060 | register Lisp_Object c; |
| 1040 | int length; | 1061 | int length; |
| 1041 | int t_ok = ! NILP (accept_default); | 1062 | int t_ok = !NILP (accept_default); |
| 1042 | struct gcpro gcpro1; | 1063 | struct gcpro gcpro1; |
| 1043 | 1064 | ||
| 1044 | keymap = get_keymap (keymap, 1, 1); | 1065 | keymap = get_keymap (keymap, 1, 1); |
| @@ -1160,8 +1181,8 @@ current_minor_maps (modeptr, mapptr) | |||
| 1160 | alist = XCDR (alist)) | 1181 | alist = XCDR (alist)) |
| 1161 | if ((assoc = XCAR (alist), CONSP (assoc)) | 1182 | if ((assoc = XCAR (alist), CONSP (assoc)) |
| 1162 | && (var = XCAR (assoc), SYMBOLP (var)) | 1183 | && (var = XCAR (assoc), SYMBOLP (var)) |
| 1163 | && (val = find_symbol_value (var), ! EQ (val, Qunbound)) | 1184 | && (val = find_symbol_value (var), !EQ (val, Qunbound)) |
| 1164 | && ! NILP (val)) | 1185 | && !NILP (val)) |
| 1165 | { | 1186 | { |
| 1166 | Lisp_Object temp; | 1187 | Lisp_Object temp; |
| 1167 | 1188 | ||
| @@ -1230,6 +1251,47 @@ current_minor_maps (modeptr, mapptr) | |||
| 1230 | return i; | 1251 | return i; |
| 1231 | } | 1252 | } |
| 1232 | 1253 | ||
| 1254 | DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps, | ||
| 1255 | 0, 1, 0, | ||
| 1256 | "Return a list of the currently active keymaps. | ||
| 1257 | OLP if non-nil indicates that we should obey `overriding-local-map' and | ||
| 1258 | `overriding-terminal-local-map'.") | ||
| 1259 | (olp) | ||
| 1260 | Lisp_Object olp; | ||
| 1261 | { | ||
| 1262 | Lisp_Object keymaps = Fcons (current_global_map, Qnil); | ||
| 1263 | |||
| 1264 | if (!NILP (olp)) | ||
| 1265 | { | ||
| 1266 | if (!NILP (Voverriding_local_map)) | ||
| 1267 | keymaps = Fcons (Voverriding_local_map, keymaps); | ||
| 1268 | if (!NILP (current_kboard->Voverriding_terminal_local_map)) | ||
| 1269 | keymaps = Fcons (current_kboard->Voverriding_terminal_local_map, keymaps); | ||
| 1270 | } | ||
| 1271 | if (NILP (XCDR (keymaps))) | ||
| 1272 | { | ||
| 1273 | Lisp_Object local; | ||
| 1274 | Lisp_Object *maps; | ||
| 1275 | int nmaps, i; | ||
| 1276 | |||
| 1277 | local = get_local_map (PT, current_buffer, Qlocal_map); | ||
| 1278 | if (!NILP (local)) | ||
| 1279 | keymaps = Fcons (local, keymaps); | ||
| 1280 | |||
| 1281 | local = get_local_map (PT, current_buffer, Qkeymap); | ||
| 1282 | if (!NILP (local)) | ||
| 1283 | keymaps = Fcons (local, keymaps); | ||
| 1284 | |||
| 1285 | nmaps = current_minor_maps (0, &maps); | ||
| 1286 | |||
| 1287 | for (i = --nmaps; i >= 0; i--) | ||
| 1288 | if (!NILP (maps[i])) | ||
| 1289 | keymaps = Fcons (maps[i], keymaps); | ||
| 1290 | } | ||
| 1291 | |||
| 1292 | return keymaps; | ||
| 1293 | } | ||
| 1294 | |||
| 1233 | /* GC is possible in this function if it autoloads a keymap. */ | 1295 | /* GC is possible in this function if it autoloads a keymap. */ |
| 1234 | 1296 | ||
| 1235 | DEFUN ("key-binding", Fkey_binding, Skey_binding, 1, 2, 0, | 1297 | DEFUN ("key-binding", Fkey_binding, Skey_binding, 1, 2, 0, |
| @@ -1459,7 +1521,64 @@ DEFUN ("current-minor-mode-maps", Fcurrent_minor_mode_maps, Scurrent_minor_mode_ | |||
| 1459 | 1521 | ||
| 1460 | /* Help functions for describing and documenting keymaps. */ | 1522 | /* Help functions for describing and documenting keymaps. */ |
| 1461 | 1523 | ||
| 1462 | static void accessible_keymaps_char_table P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); | 1524 | |
| 1525 | static void | ||
| 1526 | accessible_keymaps_1 (key, cmd, maps, tail, thisseq, is_metized) | ||
| 1527 | Lisp_Object maps, tail, thisseq, key, cmd; | ||
| 1528 | int is_metized; /* If 1, `key' is assumed to be INTEGERP. */ | ||
| 1529 | { | ||
| 1530 | Lisp_Object tem; | ||
| 1531 | |||
| 1532 | cmd = get_keyelt (cmd, 0); | ||
| 1533 | if (NILP (cmd)) | ||
| 1534 | return; | ||
| 1535 | |||
| 1536 | tem = get_keymap (cmd, 0, 0); | ||
| 1537 | if (CONSP (tem)) | ||
| 1538 | { | ||
| 1539 | cmd = tem; | ||
| 1540 | /* Ignore keymaps that are already added to maps. */ | ||
| 1541 | tem = Frassq (cmd, maps); | ||
| 1542 | if (NILP (tem)) | ||
| 1543 | { | ||
| 1544 | /* If the last key in thisseq is meta-prefix-char, | ||
| 1545 | turn it into a meta-ized keystroke. We know | ||
| 1546 | that the event we're about to append is an | ||
| 1547 | ascii keystroke since we're processing a | ||
| 1548 | keymap table. */ | ||
| 1549 | if (is_metized) | ||
| 1550 | { | ||
| 1551 | int meta_bit = meta_modifier; | ||
| 1552 | Lisp_Object last = make_number (XINT (Flength (thisseq)) - 1); | ||
| 1553 | tem = Fcopy_sequence (thisseq); | ||
| 1554 | |||
| 1555 | Faset (tem, last, make_number (XINT (key) | meta_bit)); | ||
| 1556 | |||
| 1557 | /* This new sequence is the same length as | ||
| 1558 | thisseq, so stick it in the list right | ||
| 1559 | after this one. */ | ||
| 1560 | XCDR (tail) | ||
| 1561 | = Fcons (Fcons (tem, cmd), XCDR (tail)); | ||
| 1562 | } | ||
| 1563 | else | ||
| 1564 | { | ||
| 1565 | tem = append_key (thisseq, key); | ||
| 1566 | nconc2 (tail, Fcons (Fcons (tem, cmd), Qnil)); | ||
| 1567 | } | ||
| 1568 | } | ||
| 1569 | } | ||
| 1570 | } | ||
| 1571 | |||
| 1572 | static void | ||
| 1573 | accessible_keymaps_char_table (args, index, cmd) | ||
| 1574 | Lisp_Object args, index, cmd; | ||
| 1575 | { | ||
| 1576 | accessible_keymaps_1 (index, cmd, | ||
| 1577 | XCAR (XCAR (args)), | ||
| 1578 | XCAR (XCDR (args)), | ||
| 1579 | XCDR (XCDR (args)), | ||
| 1580 | XINT (XCDR (XCAR (args)))); | ||
| 1581 | } | ||
| 1463 | 1582 | ||
| 1464 | /* This function cannot GC. */ | 1583 | /* This function cannot GC. */ |
| 1465 | 1584 | ||
| @@ -1568,89 +1687,15 @@ then the value includes only maps for prefixes that start with PREFIX.") | |||
| 1568 | 1687 | ||
| 1569 | /* Vector keymap. Scan all the elements. */ | 1688 | /* Vector keymap. Scan all the elements. */ |
| 1570 | for (i = 0; i < ASIZE (elt); i++) | 1689 | for (i = 0; i < ASIZE (elt); i++) |
| 1571 | { | 1690 | accessible_keymaps_1 (make_number (i), AREF (elt, i), |
| 1572 | register Lisp_Object tem; | 1691 | maps, tail, thisseq, is_metized); |
| 1573 | register Lisp_Object cmd; | 1692 | |
| 1574 | |||
| 1575 | cmd = get_keyelt (AREF (elt, i), 0); | ||
| 1576 | if (NILP (cmd)) continue; | ||
| 1577 | tem = get_keymap (cmd, 0, 0); | ||
| 1578 | if (CONSP (tem)) | ||
| 1579 | { | ||
| 1580 | cmd = tem; | ||
| 1581 | /* Ignore keymaps that are already added to maps. */ | ||
| 1582 | tem = Frassq (cmd, maps); | ||
| 1583 | if (NILP (tem)) | ||
| 1584 | { | ||
| 1585 | /* If the last key in thisseq is meta-prefix-char, | ||
| 1586 | turn it into a meta-ized keystroke. We know | ||
| 1587 | that the event we're about to append is an | ||
| 1588 | ascii keystroke since we're processing a | ||
| 1589 | keymap table. */ | ||
| 1590 | if (is_metized) | ||
| 1591 | { | ||
| 1592 | int meta_bit = meta_modifier; | ||
| 1593 | tem = Fcopy_sequence (thisseq); | ||
| 1594 | |||
| 1595 | Faset (tem, last, make_number (i | meta_bit)); | ||
| 1596 | |||
| 1597 | /* This new sequence is the same length as | ||
| 1598 | thisseq, so stick it in the list right | ||
| 1599 | after this one. */ | ||
| 1600 | XCDR (tail) | ||
| 1601 | = Fcons (Fcons (tem, cmd), XCDR (tail)); | ||
| 1602 | } | ||
| 1603 | else | ||
| 1604 | { | ||
| 1605 | tem = append_key (thisseq, make_number (i)); | ||
| 1606 | nconc2 (tail, Fcons (Fcons (tem, cmd), Qnil)); | ||
| 1607 | } | ||
| 1608 | } | ||
| 1609 | } | ||
| 1610 | } | ||
| 1611 | } | 1693 | } |
| 1612 | else if (CONSP (elt)) | 1694 | else if (CONSP (elt)) |
| 1613 | { | 1695 | accessible_keymaps_1 (XCAR (elt), XCDR (elt), |
| 1614 | register Lisp_Object cmd, tem; | 1696 | maps, tail, thisseq, |
| 1615 | 1697 | is_metized && INTEGERP (XCAR (elt))); | |
| 1616 | cmd = get_keyelt (XCDR (elt), 0); | 1698 | |
| 1617 | /* Ignore definitions that aren't keymaps themselves. */ | ||
| 1618 | tem = get_keymap (cmd, 0, 0); | ||
| 1619 | if (CONSP (tem)) | ||
| 1620 | { | ||
| 1621 | /* Ignore keymaps that have been seen already. */ | ||
| 1622 | cmd = tem; | ||
| 1623 | tem = Frassq (cmd, maps); | ||
| 1624 | if (NILP (tem)) | ||
| 1625 | { | ||
| 1626 | /* Let elt be the event defined by this map entry. */ | ||
| 1627 | elt = XCAR (elt); | ||
| 1628 | |||
| 1629 | /* If the last key in thisseq is meta-prefix-char, and | ||
| 1630 | this entry is a binding for an ascii keystroke, | ||
| 1631 | turn it into a meta-ized keystroke. */ | ||
| 1632 | if (is_metized && INTEGERP (elt)) | ||
| 1633 | { | ||
| 1634 | Lisp_Object element; | ||
| 1635 | |||
| 1636 | element = thisseq; | ||
| 1637 | tem = Fvconcat (1, &element); | ||
| 1638 | XSETFASTINT (AREF (tem, XINT (last)), | ||
| 1639 | XINT (elt) | meta_modifier); | ||
| 1640 | |||
| 1641 | /* This new sequence is the same length as | ||
| 1642 | thisseq, so stick it in the list right | ||
| 1643 | after this one. */ | ||
| 1644 | XCDR (tail) | ||
| 1645 | = Fcons (Fcons (tem, cmd), XCDR (tail)); | ||
| 1646 | } | ||
| 1647 | else | ||
| 1648 | nconc2 (tail, | ||
| 1649 | Fcons (Fcons (append_key (thisseq, elt), cmd), | ||
| 1650 | Qnil)); | ||
| 1651 | } | ||
| 1652 | } | ||
| 1653 | } | ||
| 1654 | } | 1699 | } |
| 1655 | } | 1700 | } |
| 1656 | 1701 | ||
| @@ -1684,59 +1729,6 @@ then the value includes only maps for prefixes that start with PREFIX.") | |||
| 1684 | 1729 | ||
| 1685 | return Fnreverse (good_maps); | 1730 | return Fnreverse (good_maps); |
| 1686 | } | 1731 | } |
| 1687 | |||
| 1688 | static void | ||
| 1689 | accessible_keymaps_char_table (args, index, cmd) | ||
| 1690 | Lisp_Object args, index, cmd; | ||
| 1691 | { | ||
| 1692 | Lisp_Object tem; | ||
| 1693 | Lisp_Object maps, tail, thisseq; | ||
| 1694 | int is_metized; | ||
| 1695 | |||
| 1696 | cmd = get_keyelt (cmd, 0); | ||
| 1697 | if (NILP (cmd)) | ||
| 1698 | return; | ||
| 1699 | |||
| 1700 | maps = XCAR (XCAR (args)); | ||
| 1701 | is_metized = XINT (XCDR (XCAR (args))); | ||
| 1702 | tail = XCAR (XCDR (args)); | ||
| 1703 | thisseq = XCDR (XCDR (args)); | ||
| 1704 | |||
| 1705 | tem = get_keymap (cmd, 0, 0); | ||
| 1706 | if (CONSP (tem)) | ||
| 1707 | { | ||
| 1708 | cmd = tem; | ||
| 1709 | /* Ignore keymaps that are already added to maps. */ | ||
| 1710 | tem = Frassq (cmd, maps); | ||
| 1711 | if (NILP (tem)) | ||
| 1712 | { | ||
| 1713 | /* If the last key in thisseq is meta-prefix-char, | ||
| 1714 | turn it into a meta-ized keystroke. We know | ||
| 1715 | that the event we're about to append is an | ||
| 1716 | ascii keystroke since we're processing a | ||
| 1717 | keymap table. */ | ||
| 1718 | if (is_metized) | ||
| 1719 | { | ||
| 1720 | int meta_bit = meta_modifier; | ||
| 1721 | Lisp_Object last = make_number (XINT (Flength (thisseq)) - 1); | ||
| 1722 | tem = Fcopy_sequence (thisseq); | ||
| 1723 | |||
| 1724 | Faset (tem, last, make_number (XINT (index) | meta_bit)); | ||
| 1725 | |||
| 1726 | /* This new sequence is the same length as | ||
| 1727 | thisseq, so stick it in the list right | ||
| 1728 | after this one. */ | ||
| 1729 | XCDR (tail) | ||
| 1730 | = Fcons (Fcons (tem, cmd), XCDR (tail)); | ||
| 1731 | } | ||
| 1732 | else | ||
| 1733 | { | ||
| 1734 | tem = append_key (thisseq, index); | ||
| 1735 | nconc2 (tail, Fcons (Fcons (tem, cmd), Qnil)); | ||
| 1736 | } | ||
| 1737 | } | ||
| 1738 | } | ||
| 1739 | } | ||
| 1740 | 1732 | ||
| 1741 | Lisp_Object Qsingle_key_description, Qkey_description; | 1733 | Lisp_Object Qsingle_key_description, Qkey_description; |
| 1742 | 1734 | ||
| @@ -2235,7 +2227,7 @@ where_is_internal (definition, keymaps, firstonly, noindirect) | |||
| 2235 | } | 2227 | } |
| 2236 | 2228 | ||
| 2237 | 2229 | ||
| 2238 | for (; ! NILP (sequences); sequences = XCDR (sequences)) | 2230 | for (; !NILP (sequences); sequences = XCDR (sequences)) |
| 2239 | { | 2231 | { |
| 2240 | Lisp_Object sequence; | 2232 | Lisp_Object sequence; |
| 2241 | 2233 | ||
| @@ -2264,7 +2256,7 @@ where_is_internal (definition, keymaps, firstonly, noindirect) | |||
| 2264 | we find. */ | 2256 | we find. */ |
| 2265 | if (EQ (firstonly, Qnon_ascii)) | 2257 | if (EQ (firstonly, Qnon_ascii)) |
| 2266 | RETURN_UNGCPRO (sequence); | 2258 | RETURN_UNGCPRO (sequence); |
| 2267 | else if (! NILP (firstonly) && ascii_sequence_p (sequence)) | 2259 | else if (!NILP (firstonly) && ascii_sequence_p (sequence)) |
| 2268 | RETURN_UNGCPRO (sequence); | 2260 | RETURN_UNGCPRO (sequence); |
| 2269 | } | 2261 | } |
| 2270 | } | 2262 | } |
| @@ -2277,7 +2269,7 @@ where_is_internal (definition, keymaps, firstonly, noindirect) | |||
| 2277 | /* firstonly may have been t, but we may have gone all the way through | 2269 | /* firstonly may have been t, but we may have gone all the way through |
| 2278 | the keymaps without finding an all-ASCII key sequence. So just | 2270 | the keymaps without finding an all-ASCII key sequence. So just |
| 2279 | return the best we could find. */ | 2271 | return the best we could find. */ |
| 2280 | if (! NILP (firstonly)) | 2272 | if (!NILP (firstonly)) |
| 2281 | return Fcar (found); | 2273 | return Fcar (found); |
| 2282 | 2274 | ||
| 2283 | return found; | 2275 | return found; |
| @@ -2311,16 +2303,10 @@ indirect definition itself.") | |||
| 2311 | /* Find the relevant keymaps. */ | 2303 | /* Find the relevant keymaps. */ |
| 2312 | if (CONSP (keymap) && KEYMAPP (XCAR (keymap))) | 2304 | if (CONSP (keymap) && KEYMAPP (XCAR (keymap))) |
| 2313 | keymaps = keymap; | 2305 | keymaps = keymap; |
| 2314 | else if (! NILP (keymap)) | 2306 | else if (!NILP (keymap)) |
| 2315 | keymaps = Fcons (keymap, Fcons (current_global_map, Qnil)); | 2307 | keymaps = Fcons (keymap, Fcons (current_global_map, Qnil)); |
| 2316 | else | 2308 | else |
| 2317 | keymaps = | 2309 | keymaps = Fcurrent_active_maps (Qnil); |
| 2318 | Fdelq (Qnil, | ||
| 2319 | nconc2 (Fcurrent_minor_mode_maps (), | ||
| 2320 | Fcons (get_local_map (PT, current_buffer, Qkeymap), | ||
| 2321 | Fcons (get_local_map (PT, current_buffer, | ||
| 2322 | Qlocal_map), | ||
| 2323 | Fcons (current_global_map, Qnil))))); | ||
| 2324 | 2310 | ||
| 2325 | /* Only use caching for the menubar (i.e. called with (def nil t nil). | 2311 | /* Only use caching for the menubar (i.e. called with (def nil t nil). |
| 2326 | We don't really need to check `keymap'. */ | 2312 | We don't really need to check `keymap'. */ |
| @@ -2488,14 +2474,19 @@ then we display only bindings that start with that prefix.") | |||
| 2488 | return Qnil; | 2474 | return Qnil; |
| 2489 | } | 2475 | } |
| 2490 | 2476 | ||
| 2491 | /* ARG is (BUFFER PREFIX MENU-FLAG). */ | 2477 | DEFUN ("describe-buffer-bindings", Fdescribe_buffer_bindings, Sdescribe_buffer_bindings, 1, 3, 0, |
| 2492 | 2478 | "Insert the list of all defined keys and their definitions.\n\ | |
| 2493 | static Lisp_Object | 2479 | The list is inserted in the current buffer, while the bindings are\n\ |
| 2494 | describe_buffer_bindings (arg) | 2480 | looked up in BUFFER.\n\ |
| 2495 | Lisp_Object arg; | 2481 | The optional argument PREFIX, if non-nil, should be a key sequence;\n\ |
| 2482 | then we display only bindings that start with that prefix.\n\ | ||
| 2483 | The optional argument MENUS, if non-nil, says to mention menu bindings.\n\ | ||
| 2484 | \(Ordinarily these are omitted from the output.)") | ||
| 2485 | (buffer, prefix, menus) | ||
| 2486 | Lisp_Object buffer, prefix, menus; | ||
| 2496 | { | 2487 | { |
| 2497 | Lisp_Object descbuf, prefix, shadow; | 2488 | Lisp_Object outbuf, shadow; |
| 2498 | int nomenu; | 2489 | int nomenu = NILP (menus); |
| 2499 | register Lisp_Object start1; | 2490 | register Lisp_Object start1; |
| 2500 | struct gcpro gcpro1; | 2491 | struct gcpro gcpro1; |
| 2501 | 2492 | ||
| @@ -2505,16 +2496,10 @@ Keyboard translations:\n\n\ | |||
| 2505 | You type Translation\n\ | 2496 | You type Translation\n\ |
| 2506 | -------- -----------\n"; | 2497 | -------- -----------\n"; |
| 2507 | 2498 | ||
| 2508 | descbuf = XCAR (arg); | ||
| 2509 | arg = XCDR (arg); | ||
| 2510 | prefix = XCAR (arg); | ||
| 2511 | arg = XCDR (arg); | ||
| 2512 | nomenu = NILP (XCAR (arg)); | ||
| 2513 | |||
| 2514 | shadow = Qnil; | 2499 | shadow = Qnil; |
| 2515 | GCPRO1 (shadow); | 2500 | GCPRO1 (shadow); |
| 2516 | 2501 | ||
| 2517 | Fset_buffer (Vstandard_output); | 2502 | outbuf = Fcurrent_buffer(); |
| 2518 | 2503 | ||
| 2519 | /* Report on alternates for keys. */ | 2504 | /* Report on alternates for keys. */ |
| 2520 | if (STRINGP (Vkeyboard_translate_table) && !NILP (prefix)) | 2505 | if (STRINGP (Vkeyboard_translate_table) && !NILP (prefix)) |
| @@ -2555,16 +2540,16 @@ You type Translation\n\ | |||
| 2555 | int i, nmaps; | 2540 | int i, nmaps; |
| 2556 | Lisp_Object *modes, *maps; | 2541 | Lisp_Object *modes, *maps; |
| 2557 | 2542 | ||
| 2558 | /* Temporarily switch to descbuf, so that we can get that buffer's | 2543 | /* Temporarily switch to `buffer', so that we can get that buffer's |
| 2559 | minor modes correctly. */ | 2544 | minor modes correctly. */ |
| 2560 | Fset_buffer (descbuf); | 2545 | Fset_buffer (buffer); |
| 2561 | 2546 | ||
| 2562 | if (!NILP (current_kboard->Voverriding_terminal_local_map) | 2547 | if (!NILP (current_kboard->Voverriding_terminal_local_map) |
| 2563 | || !NILP (Voverriding_local_map)) | 2548 | || !NILP (Voverriding_local_map)) |
| 2564 | nmaps = 0; | 2549 | nmaps = 0; |
| 2565 | else | 2550 | else |
| 2566 | nmaps = current_minor_maps (&modes, &maps); | 2551 | nmaps = current_minor_maps (&modes, &maps); |
| 2567 | Fset_buffer (Vstandard_output); | 2552 | Fset_buffer (outbuf); |
| 2568 | 2553 | ||
| 2569 | /* Print the minor mode maps. */ | 2554 | /* Print the minor mode maps. */ |
| 2570 | for (i = 0; i < nmaps; i++) | 2555 | for (i = 0; i < nmaps; i++) |
| @@ -2601,7 +2586,7 @@ You type Translation\n\ | |||
| 2601 | else if (!NILP (Voverriding_local_map)) | 2586 | else if (!NILP (Voverriding_local_map)) |
| 2602 | start1 = Voverriding_local_map; | 2587 | start1 = Voverriding_local_map; |
| 2603 | else | 2588 | else |
| 2604 | start1 = XBUFFER (descbuf)->keymap; | 2589 | start1 = XBUFFER (buffer)->keymap; |
| 2605 | 2590 | ||
| 2606 | if (!NILP (start1)) | 2591 | if (!NILP (start1)) |
| 2607 | { | 2592 | { |
| @@ -2618,12 +2603,22 @@ You type Translation\n\ | |||
| 2618 | describe_map_tree (Vfunction_key_map, 0, Qnil, prefix, | 2603 | describe_map_tree (Vfunction_key_map, 0, Qnil, prefix, |
| 2619 | "\f\nFunction key map translations", nomenu, 1, 0); | 2604 | "\f\nFunction key map translations", nomenu, 1, 0); |
| 2620 | 2605 | ||
| 2621 | call0 (intern ("help-mode")); | ||
| 2622 | Fset_buffer (descbuf); | ||
| 2623 | UNGCPRO; | 2606 | UNGCPRO; |
| 2624 | return Qnil; | 2607 | return Qnil; |
| 2625 | } | 2608 | } |
| 2626 | 2609 | ||
| 2610 | /* ARG is (BUFFER PREFIX MENU-FLAG). */ | ||
| 2611 | |||
| 2612 | static Lisp_Object | ||
| 2613 | describe_buffer_bindings (arg) | ||
| 2614 | Lisp_Object arg; | ||
| 2615 | { | ||
| 2616 | Fset_buffer (Vstandard_output); | ||
| 2617 | return Fdescribe_buffer_bindings (XCAR (arg), XCAR (XCDR (arg)), | ||
| 2618 | XCAR (XCDR (XCDR (arg)))); | ||
| 2619 | } | ||
| 2620 | |||
| 2621 | |||
| 2627 | /* Insert a description of the key bindings in STARTMAP, | 2622 | /* Insert a description of the key bindings in STARTMAP, |
| 2628 | followed by those of all maps reachable through STARTMAP. | 2623 | followed by those of all maps reachable through STARTMAP. |
| 2629 | If PARTIAL is nonzero, omit certain "uninteresting" commands | 2624 | If PARTIAL is nonzero, omit certain "uninteresting" commands |
| @@ -2741,11 +2736,11 @@ key binding\n\ | |||
| 2741 | } | 2736 | } |
| 2742 | 2737 | ||
| 2743 | /* Maps we have already listed in this loop shadow this map. */ | 2738 | /* Maps we have already listed in this loop shadow this map. */ |
| 2744 | for (tail = orig_maps; ! EQ (tail, maps); tail = XCDR (tail)) | 2739 | for (tail = orig_maps; !EQ (tail, maps); tail = XCDR (tail)) |
| 2745 | { | 2740 | { |
| 2746 | Lisp_Object tem; | 2741 | Lisp_Object tem; |
| 2747 | tem = Fequal (Fcar (XCAR (tail)), prefix); | 2742 | tem = Fequal (Fcar (XCAR (tail)), prefix); |
| 2748 | if (! NILP (tem)) | 2743 | if (!NILP (tem)) |
| 2749 | sub_shadows = Fcons (XCDR (XCAR (tail)), sub_shadows); | 2744 | sub_shadows = Fcons (XCDR (XCAR (tail)), sub_shadows); |
| 2750 | } | 2745 | } |
| 2751 | 2746 | ||
| @@ -2885,7 +2880,7 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) | |||
| 2885 | 2880 | ||
| 2886 | /* Ignore bindings whose "keys" are not really valid events. | 2881 | /* Ignore bindings whose "keys" are not really valid events. |
| 2887 | (We get these in the frames and buffers menu.) */ | 2882 | (We get these in the frames and buffers menu.) */ |
| 2888 | if (! (SYMBOLP (event) || INTEGERP (event))) | 2883 | if (!(SYMBOLP (event) || INTEGERP (event))) |
| 2889 | continue; | 2884 | continue; |
| 2890 | 2885 | ||
| 2891 | if (nomenu && EQ (event, Qmenu_bar)) | 2886 | if (nomenu && EQ (event, Qmenu_bar)) |
| @@ -2913,7 +2908,7 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) | |||
| 2913 | } | 2908 | } |
| 2914 | 2909 | ||
| 2915 | tem = Flookup_key (map, kludge, Qt); | 2910 | tem = Flookup_key (map, kludge, Qt); |
| 2916 | if (! EQ (tem, definition)) continue; | 2911 | if (!EQ (tem, definition)) continue; |
| 2917 | 2912 | ||
| 2918 | if (first) | 2913 | if (first) |
| 2919 | { | 2914 | { |
| @@ -3155,7 +3150,7 @@ describe_vector (vector, elt_prefix, elt_describer, | |||
| 3155 | ASET (kludge, 0, make_number (character)); | 3150 | ASET (kludge, 0, make_number (character)); |
| 3156 | tem = Flookup_key (entire_map, kludge, Qt); | 3151 | tem = Flookup_key (entire_map, kludge, Qt); |
| 3157 | 3152 | ||
| 3158 | if (! EQ (tem, definition)) | 3153 | if (!EQ (tem, definition)) |
| 3159 | continue; | 3154 | continue; |
| 3160 | } | 3155 | } |
| 3161 | 3156 | ||
| @@ -3456,6 +3451,7 @@ and applies even for keys that have ordinary bindings."); | |||
| 3456 | 3451 | ||
| 3457 | defsubr (&Skeymapp); | 3452 | defsubr (&Skeymapp); |
| 3458 | defsubr (&Skeymap_parent); | 3453 | defsubr (&Skeymap_parent); |
| 3454 | defsubr (&Skeymap_prompt); | ||
| 3459 | defsubr (&Sset_keymap_parent); | 3455 | defsubr (&Sset_keymap_parent); |
| 3460 | defsubr (&Smake_keymap); | 3456 | defsubr (&Smake_keymap); |
| 3461 | defsubr (&Smake_sparse_keymap); | 3457 | defsubr (&Smake_sparse_keymap); |
| @@ -3472,6 +3468,7 @@ and applies even for keys that have ordinary bindings."); | |||
| 3472 | defsubr (&Scurrent_local_map); | 3468 | defsubr (&Scurrent_local_map); |
| 3473 | defsubr (&Scurrent_global_map); | 3469 | defsubr (&Scurrent_global_map); |
| 3474 | defsubr (&Scurrent_minor_mode_maps); | 3470 | defsubr (&Scurrent_minor_mode_maps); |
| 3471 | defsubr (&Scurrent_active_maps); | ||
| 3475 | defsubr (&Saccessible_keymaps); | 3472 | defsubr (&Saccessible_keymaps); |
| 3476 | defsubr (&Skey_description); | 3473 | defsubr (&Skey_description); |
| 3477 | defsubr (&Sdescribe_vector); | 3474 | defsubr (&Sdescribe_vector); |
| @@ -3479,6 +3476,7 @@ and applies even for keys that have ordinary bindings."); | |||
| 3479 | defsubr (&Stext_char_description); | 3476 | defsubr (&Stext_char_description); |
| 3480 | defsubr (&Swhere_is_internal); | 3477 | defsubr (&Swhere_is_internal); |
| 3481 | defsubr (&Sdescribe_bindings_internal); | 3478 | defsubr (&Sdescribe_bindings_internal); |
| 3479 | defsubr (&Sdescribe_buffer_bindings); | ||
| 3482 | defsubr (&Sapropos_internal); | 3480 | defsubr (&Sapropos_internal); |
| 3483 | } | 3481 | } |
| 3484 | 3482 | ||