Mercurial > emacs
comparison src/keymap.c @ 74574:3c809b430d91
(Flookup_key): Doc fix.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Sun, 10 Dec 2006 23:33:46 +0000 |
parents | 1a3368a80879 |
children | 489131611785 6588c6259dfb |
comparison
equal
deleted
inserted
replaced
74573:1341133a3cd9 | 74574:3c809b430d91 |
---|---|
1245 /* Value is number if KEY is too long; nil if valid but has no definition. */ | 1245 /* Value is number if KEY is too long; nil if valid but has no definition. */ |
1246 /* GC is possible in this function if it autoloads a keymap. */ | 1246 /* GC is possible in this function if it autoloads a keymap. */ |
1247 | 1247 |
1248 DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0, | 1248 DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0, |
1249 doc: /* In keymap KEYMAP, look up key sequence KEY. Return the definition. | 1249 doc: /* In keymap KEYMAP, look up key sequence KEY. Return the definition. |
1250 nil means undefined. See doc of `define-key' for kinds of definitions. | 1250 A value of nil means undefined. See doc of `define-key' |
1251 for kinds of definitions. | |
1251 | 1252 |
1252 A number as value means KEY is "too long"; | 1253 A number as value means KEY is "too long"; |
1253 that is, characters or symbols in it except for the last one | 1254 that is, characters or symbols in it except for the last one |
1254 fail to be a valid sequence of prefix characters in KEYMAP. | 1255 fail to be a valid sequence of prefix characters in KEYMAP. |
1255 The number is how many characters at the front of KEY | 1256 The number is how many characters at the front of KEY |
1620 | 1621 |
1621 /* Key sequences beginning with mouse clicks | 1622 /* Key sequences beginning with mouse clicks |
1622 are read using the keymaps of the buffer clicked on, not | 1623 are read using the keymaps of the buffer clicked on, not |
1623 the current buffer. So we may have to switch the buffer | 1624 the current buffer. So we may have to switch the buffer |
1624 here. */ | 1625 here. */ |
1625 | 1626 |
1626 if (CONSP (position)) | 1627 if (CONSP (position)) |
1627 { | 1628 { |
1628 Lisp_Object window; | 1629 Lisp_Object window; |
1629 | 1630 |
1630 window = POSN_WINDOW (position); | 1631 window = POSN_WINDOW (position); |
1631 | 1632 |
1632 if (WINDOWP (window) | 1633 if (WINDOWP (window) |
1633 && BUFFERP (XWINDOW (window)->buffer) | 1634 && BUFFERP (XWINDOW (window)->buffer) |
1634 && XBUFFER (XWINDOW (window)->buffer) != current_buffer) | 1635 && XBUFFER (XWINDOW (window)->buffer) != current_buffer) |
1635 { | 1636 { |
1636 /* Arrange to go back to the original buffer once we're done | 1637 /* Arrange to go back to the original buffer once we're done |
1638 save_excursion_{save,restore} here, in analogy to | 1639 save_excursion_{save,restore} here, in analogy to |
1639 `read-key-sequence' to avoid saving point. Maybe this | 1640 `read-key-sequence' to avoid saving point. Maybe this |
1640 would not be a problem here, but it is easier to keep | 1641 would not be a problem here, but it is easier to keep |
1641 things the same. | 1642 things the same. |
1642 */ | 1643 */ |
1643 | 1644 |
1644 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 1645 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
1645 | 1646 |
1646 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); | 1647 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); |
1647 } | 1648 } |
1648 } | 1649 } |
1649 | 1650 |
1650 if (! NILP (current_kboard->Voverriding_terminal_local_map)) | 1651 if (! NILP (current_kboard->Voverriding_terminal_local_map)) |
1651 { | 1652 { |
1652 value = Flookup_key (current_kboard->Voverriding_terminal_local_map, | 1653 value = Flookup_key (current_kboard->Voverriding_terminal_local_map, |
1653 key, accept_default); | 1654 key, accept_default); |
1654 if (! NILP (value) && !INTEGERP (value)) | 1655 if (! NILP (value) && !INTEGERP (value)) |
1667 | 1668 |
1668 pt = INTEGERP (position) ? XINT (position) | 1669 pt = INTEGERP (position) ? XINT (position) |
1669 : MARKERP (position) ? marker_position (position) | 1670 : MARKERP (position) ? marker_position (position) |
1670 : PT; | 1671 : PT; |
1671 | 1672 |
1672 local_map = get_local_map (pt, current_buffer, Qlocal_map); | 1673 local_map = get_local_map (pt, current_buffer, Qlocal_map); |
1673 keymap = get_local_map (pt, current_buffer, Qkeymap); | 1674 keymap = get_local_map (pt, current_buffer, Qkeymap); |
1674 | 1675 |
1675 if (CONSP (position)) | 1676 if (CONSP (position)) |
1676 { | 1677 { |
1677 Lisp_Object string; | 1678 Lisp_Object string; |
1678 | 1679 |
1679 /* For a mouse click, get the local text-property keymap | 1680 /* For a mouse click, get the local text-property keymap |
1680 of the place clicked on, rather than point. */ | 1681 of the place clicked on, rather than point. */ |
1681 | 1682 |
1682 if (POSN_INBUFFER_P (position)) | 1683 if (POSN_INBUFFER_P (position)) |
1683 { | 1684 { |
1684 Lisp_Object pos; | 1685 Lisp_Object pos; |
1685 | 1686 |
1686 pos = POSN_BUFFER_POSN (position); | 1687 pos = POSN_BUFFER_POSN (position); |
1687 if (INTEGERP (pos) | 1688 if (INTEGERP (pos) |
1688 && XINT (pos) >= BEG && XINT (pos) <= Z) | 1689 && XINT (pos) >= BEG && XINT (pos) <= Z) |
1689 { | 1690 { |
1690 local_map = get_local_map (XINT (pos), | 1691 local_map = get_local_map (XINT (pos), |
1691 current_buffer, Qlocal_map); | 1692 current_buffer, Qlocal_map); |
1692 | 1693 |
1693 keymap = get_local_map (XINT (pos), | 1694 keymap = get_local_map (XINT (pos), |
1694 current_buffer, Qkeymap); | 1695 current_buffer, Qkeymap); |
1695 } | 1696 } |
1696 } | 1697 } |
1697 | 1698 |
1698 /* If on a mode line string with a local keymap, | 1699 /* If on a mode line string with a local keymap, |
1699 or for a click on a string, i.e. overlay string or a | 1700 or for a click on a string, i.e. overlay string or a |
1700 string displayed via the `display' property, | 1701 string displayed via the `display' property, |
1701 consider `local-map' and `keymap' properties of | 1702 consider `local-map' and `keymap' properties of |
1702 that string. */ | 1703 that string. */ |
1703 | 1704 |
1704 if (string = POSN_STRING (position), | 1705 if (string = POSN_STRING (position), |
1705 (CONSP (string) && STRINGP (XCAR (string)))) | 1706 (CONSP (string) && STRINGP (XCAR (string)))) |
1706 { | 1707 { |
1707 Lisp_Object pos, map; | 1708 Lisp_Object pos, map; |
1708 | 1709 |
1709 pos = XCDR (string); | 1710 pos = XCDR (string); |
1710 string = XCAR (string); | 1711 string = XCAR (string); |
1711 if (INTEGERP (pos) | 1712 if (INTEGERP (pos) |
1712 && XINT (pos) >= 0 | 1713 && XINT (pos) >= 0 |
1713 && XINT (pos) < SCHARS (string)) | 1714 && XINT (pos) < SCHARS (string)) |
1719 map = Fget_text_property (pos, Qkeymap, string); | 1720 map = Fget_text_property (pos, Qkeymap, string); |
1720 if (!NILP (map)) | 1721 if (!NILP (map)) |
1721 keymap = map; | 1722 keymap = map; |
1722 } | 1723 } |
1723 } | 1724 } |
1724 | 1725 |
1725 } | 1726 } |
1726 | 1727 |
1727 if (! NILP (keymap)) | 1728 if (! NILP (keymap)) |
1728 { | 1729 { |
1729 value = Flookup_key (keymap, key, accept_default); | 1730 value = Flookup_key (keymap, key, accept_default); |