aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Kastrup2007-06-25 20:53:48 +0000
committerDavid Kastrup2007-06-25 20:53:48 +0000
commit9a51747bac45695aba40b3595c55237196b0fdcd (patch)
treec43b54d74f3bae9aa2bc64aaa860dd51924d8a27 /src
parente43054262b4764a7a6440f0c3cf6a1402d10c77a (diff)
downloademacs-9a51747bac45695aba40b3595c55237196b0fdcd.tar.gz
emacs-9a51747bac45695aba40b3595c55237196b0fdcd.zip
* keymaps.texi (Active Keymaps): Document new POSITION argument of
`current-active-maps'. * keymap.c (Fcurrent_active_maps): Add `position' argument. (Fwhere_is_internal): Adjust call to `current-active-maps' to cater for additional parameter. * keymap.h: Adjust number of parameters to `current-active-maps'. * doc.c (Fsubstitute_command_keys): Adjust call of `current-active-maps'.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/doc.c2
-rw-r--r--src/keymap.c126
-rw-r--r--src/keymap.h2
4 files changed, 123 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b425016766c..1087913f2a8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,16 @@
12007-06-25 David Kastrup <dak@gnu.org> 12007-06-25 David Kastrup <dak@gnu.org>
2 2
3 * keymap.c (Fcurrent_active_maps): Add `position' argument.
4 (Fwhere_is_internal): Adjust call to `current-active-maps' to
5 cater for additional parameter.
6
7 * keymap.h: Adjust number of parameters to `current-active-maps'.
8
9 * doc.c (Fsubstitute_command_keys): Adjust call of
10 `current-active-maps'.
11
122007-06-25 David Kastrup <dak@gnu.org>
13
3 * callint.c (Fcall_interactively): Make the parsing of interactive 14 * callint.c (Fcall_interactively): Make the parsing of interactive
4 specs somewhat more readable. 15 specs somewhat more readable.
5 16
diff --git a/src/doc.c b/src/doc.c
index 39fa6229183..c0d4961606b 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -883,7 +883,7 @@ a new string, without any text properties, is returned. */)
883 struct buffer *oldbuf; 883 struct buffer *oldbuf;
884 int start_idx; 884 int start_idx;
885 /* This is for computing the SHADOWS arg for describe_map_tree. */ 885 /* This is for computing the SHADOWS arg for describe_map_tree. */
886 Lisp_Object active_maps = Fcurrent_active_maps (Qnil); 886 Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil);
887 Lisp_Object earlier_maps; 887 Lisp_Object earlier_maps;
888 888
889 changed = 1; 889 changed = 1;
diff --git a/src/keymap.c b/src/keymap.c
index 109ef250c8b..f9071f9c633 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1541,14 +1541,47 @@ current_minor_maps (modeptr, mapptr)
1541} 1541}
1542 1542
1543DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps, 1543DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps,
1544 0, 1, 0, 1544 0, 2, 0,
1545 doc: /* Return a list of the currently active keymaps. 1545 doc: /* Return a list of the currently active keymaps.
1546OLP if non-nil indicates that we should obey `overriding-local-map' and 1546OLP if non-nil indicates that we should obey `overriding-local-map' and
1547`overriding-terminal-local-map'. */) 1547`overriding-terminal-local-map'. POSITION can specify a click position
1548 (olp) 1548like in the respective argument of `key-binding'. */)
1549 Lisp_Object olp; 1549 (olp, position)
1550 Lisp_Object olp, position;
1550{ 1551{
1551 Lisp_Object keymaps = Fcons (current_global_map, Qnil); 1552 int count = SPECPDL_INDEX ();
1553
1554 Lisp_Object keymaps;
1555
1556 /* If a mouse click position is given, our variables are based on
1557 the buffer clicked on, not the current buffer. So we may have to
1558 switch the buffer here. */
1559
1560 if (CONSP (position))
1561 {
1562 Lisp_Object window;
1563
1564 window = POSN_WINDOW (position);
1565
1566 if (WINDOWP (window)
1567 && BUFFERP (XWINDOW (window)->buffer)
1568 && XBUFFER (XWINDOW (window)->buffer) != current_buffer)
1569 {
1570 /* Arrange to go back to the original buffer once we're done
1571 processing the key sequence. We don't use
1572 save_excursion_{save,restore} here, in analogy to
1573 `read-key-sequence' to avoid saving point. Maybe this
1574 would not be a problem here, but it is easier to keep
1575 things the same.
1576 */
1577
1578 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
1579
1580 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer));
1581 }
1582 }
1583
1584 keymaps = Fcons (current_global_map, Qnil);
1552 1585
1553 if (!NILP (olp)) 1586 if (!NILP (olp))
1554 { 1587 {
@@ -1562,15 +1595,76 @@ OLP if non-nil indicates that we should obey `overriding-local-map' and
1562 } 1595 }
1563 if (NILP (XCDR (keymaps))) 1596 if (NILP (XCDR (keymaps)))
1564 { 1597 {
1565 Lisp_Object local;
1566 Lisp_Object *maps; 1598 Lisp_Object *maps;
1567 int nmaps, i; 1599 int nmaps, i;
1568 1600
1569 /* This usually returns the buffer's local map, 1601 Lisp_Object keymap, local_map;
1570 but that can be overridden by a `local-map' property. */ 1602 EMACS_INT pt;
1571 local = get_local_map (PT, current_buffer, Qlocal_map); 1603
1572 if (!NILP (local)) 1604 pt = INTEGERP (position) ? XINT (position)
1573 keymaps = Fcons (local, keymaps); 1605 : MARKERP (position) ? marker_position (position)
1606 : PT;
1607
1608 /* Get the buffer local maps, possibly overriden by text or
1609 overlay properties */
1610
1611 local_map = get_local_map (pt, current_buffer, Qlocal_map);
1612 keymap = get_local_map (pt, current_buffer, Qkeymap);
1613
1614 if (CONSP (position))
1615 {
1616 Lisp_Object string;
1617
1618 /* For a mouse click, get the local text-property keymap
1619 of the place clicked on, rather than point. */
1620
1621 if (POSN_INBUFFER_P (position))
1622 {
1623 Lisp_Object pos;
1624
1625 pos = POSN_BUFFER_POSN (position);
1626 if (INTEGERP (pos)
1627 && XINT (pos) >= BEG && XINT (pos) <= Z)
1628 {
1629 local_map = get_local_map (XINT (pos),
1630 current_buffer, Qlocal_map);
1631
1632 keymap = get_local_map (XINT (pos),
1633 current_buffer, Qkeymap);
1634 }
1635 }
1636
1637 /* If on a mode line string with a local keymap,
1638 or for a click on a string, i.e. overlay string or a
1639 string displayed via the `display' property,
1640 consider `local-map' and `keymap' properties of
1641 that string. */
1642
1643 if (string = POSN_STRING (position),
1644 (CONSP (string) && STRINGP (XCAR (string))))
1645 {
1646 Lisp_Object pos, map;
1647
1648 pos = XCDR (string);
1649 string = XCAR (string);
1650 if (INTEGERP (pos)
1651 && XINT (pos) >= 0
1652 && XINT (pos) < SCHARS (string))
1653 {
1654 map = Fget_text_property (pos, Qlocal_map, string);
1655 if (!NILP (map))
1656 local_map = map;
1657
1658 map = Fget_text_property (pos, Qkeymap, string);
1659 if (!NILP (map))
1660 keymap = map;
1661 }
1662 }
1663
1664 }
1665
1666 if (!NILP (local_map))
1667 keymaps = Fcons (local_map, keymaps);
1574 1668
1575 /* Now put all the minor mode keymaps on the list. */ 1669 /* Now put all the minor mode keymaps on the list. */
1576 nmaps = current_minor_maps (0, &maps); 1670 nmaps = current_minor_maps (0, &maps);
@@ -1579,12 +1673,12 @@ OLP if non-nil indicates that we should obey `overriding-local-map' and
1579 if (!NILP (maps[i])) 1673 if (!NILP (maps[i]))
1580 keymaps = Fcons (maps[i], keymaps); 1674 keymaps = Fcons (maps[i], keymaps);
1581 1675
1582 /* This returns nil unless there is a `keymap' property. */ 1676 if (!NILP (keymap))
1583 local = get_local_map (PT, current_buffer, Qkeymap); 1677 keymaps = Fcons (keymap, keymaps);
1584 if (!NILP (local))
1585 keymaps = Fcons (local, keymaps);
1586 } 1678 }
1587 1679
1680 unbind_to (count, Qnil);
1681
1588 return keymaps; 1682 return keymaps;
1589} 1683}
1590 1684
@@ -2842,7 +2936,7 @@ remapped command in the returned list. */)
2842 else if (!NILP (keymap)) 2936 else if (!NILP (keymap))
2843 keymaps = Fcons (keymap, Fcons (current_global_map, Qnil)); 2937 keymaps = Fcons (keymap, Fcons (current_global_map, Qnil));
2844 else 2938 else
2845 keymaps = Fcurrent_active_maps (Qnil); 2939 keymaps = Fcurrent_active_maps (Qnil, Qnil);
2846 2940
2847 /* Only use caching for the menubar (i.e. called with (def nil t nil). 2941 /* Only use caching for the menubar (i.e. called with (def nil t nil).
2848 We don't really need to check `keymap'. */ 2942 We don't really need to check `keymap'. */
diff --git a/src/keymap.h b/src/keymap.h
index f55f76d5005..185ae70d945 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -34,7 +34,7 @@ EXFUN (Fkey_binding, 4);
34EXFUN (Fkey_description, 2); 34EXFUN (Fkey_description, 2);
35EXFUN (Fsingle_key_description, 2); 35EXFUN (Fsingle_key_description, 2);
36EXFUN (Fwhere_is_internal, 5); 36EXFUN (Fwhere_is_internal, 5);
37EXFUN (Fcurrent_active_maps, 1); 37EXFUN (Fcurrent_active_maps, 2);
38extern Lisp_Object access_keymap P_ ((Lisp_Object, Lisp_Object, int, int, int)); 38extern Lisp_Object access_keymap P_ ((Lisp_Object, Lisp_Object, int, int, int));
39extern Lisp_Object get_keyelt P_ ((Lisp_Object, int)); 39extern Lisp_Object get_keyelt P_ ((Lisp_Object, int));
40extern Lisp_Object get_keymap P_ ((Lisp_Object, int, int)); 40extern Lisp_Object get_keymap P_ ((Lisp_Object, int, int));