diff options
| author | Spencer Baugh | 2025-08-28 14:13:24 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2025-09-09 18:02:24 -0400 |
| commit | 0e9cee2bf5d97a23c47d99ffc47396dcd3bd50ee (patch) | |
| tree | 66d451585272981ff2383580e4e5fbbf9dcf760a /src | |
| parent | 82f6c1651435aac656de7116511bf290bb0ef3e4 (diff) | |
| download | emacs-0e9cee2bf5d97a23c47d99ffc47396dcd3bd50ee.tar.gz emacs-0e9cee2bf5d97a23c47d99ffc47396dcd3bd50ee.zip | |
Ignore keymaps at point for positions outside the buffer
Correct a few edge cases where we used the keymaps at point when
looking up keymaps for an event position which is outside the
current buffer. Namely:
- Clicking on a part of the mode line which is after the end of
mode-line-format produces an event with non-nil posn-area but
nil posn-string.
- Even if posn-string doesn't have a local keymap, we should
still ignore the keymaps at point if posn-string is non-nil.
* src/keymap.c (Fcurrent_active_maps): Ignore keymaps at point
for more positions outside the buffer. (bug#76620)
Diffstat (limited to 'src')
| -rw-r--r-- | src/keymap.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/src/keymap.c b/src/keymap.c index 2c250578b00..295b209f06b 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -1735,11 +1735,20 @@ means to return the active maps for that window's buffer. */) | |||
| 1735 | } | 1735 | } |
| 1736 | } | 1736 | } |
| 1737 | 1737 | ||
| 1738 | /* If on a mode line string with a local keymap, | 1738 | Lisp_Object pos_area = POSN_POSN (position); |
| 1739 | or for a click on a string, i.e. overlay string or a | 1739 | if (EQ (pos_area, Qmode_line) || EQ (pos_area, Qheader_line)) |
| 1740 | string displayed via the `display' property, | 1740 | { |
| 1741 | consider `local-map' and `keymap' properties of | 1741 | /* For clicks on mode line or header line, ignore the maps |
| 1742 | that string. */ | 1742 | we found at POSITION, because properties at point are |
| 1743 | not relevant in that case. */ | ||
| 1744 | local_map = Qnil; | ||
| 1745 | keymap = Qnil; | ||
| 1746 | } | ||
| 1747 | |||
| 1748 | /* If on a mode line string with a local keymap, or for a | ||
| 1749 | click on a string, i.e. overlay string or a string | ||
| 1750 | displayed via the `display' property, consider only the | ||
| 1751 | `local-map' and `keymap' properties of that string. */ | ||
| 1743 | 1752 | ||
| 1744 | if (CONSP (string) && STRINGP (XCAR (string))) | 1753 | if (CONSP (string) && STRINGP (XCAR (string))) |
| 1745 | { | 1754 | { |
| @@ -1749,23 +1758,8 @@ means to return the active maps for that window's buffer. */) | |||
| 1749 | && XFIXNUM (pos) >= 0 | 1758 | && XFIXNUM (pos) >= 0 |
| 1750 | && XFIXNUM (pos) < SCHARS (string)) | 1759 | && XFIXNUM (pos) < SCHARS (string)) |
| 1751 | { | 1760 | { |
| 1752 | Lisp_Object map = Fget_text_property (pos, Qlocal_map, | 1761 | local_map = Fget_text_property (pos, Qlocal_map, string); |
| 1753 | string); | 1762 | keymap = Fget_text_property (pos, Qkeymap, string); |
| 1754 | Lisp_Object pos_area = POSN_POSN (position); | ||
| 1755 | /* For clicks on mode line or header line, override | ||
| 1756 | the maps we found at POSITION unconditionally, even | ||
| 1757 | if the corresponding properties of the mode- or | ||
| 1758 | header-line string are nil, because propertries at | ||
| 1759 | point are not relevant in that case. */ | ||
| 1760 | if (!NILP (map) | ||
| 1761 | || EQ (pos_area, Qmode_line) | ||
| 1762 | || EQ (pos_area, Qheader_line)) | ||
| 1763 | local_map = map; | ||
| 1764 | map = Fget_text_property (pos, Qkeymap, string); | ||
| 1765 | if (!NILP (map) | ||
| 1766 | || EQ (pos_area, Qmode_line) | ||
| 1767 | || EQ (pos_area, Qheader_line)) | ||
| 1768 | keymap = map; | ||
| 1769 | } | 1763 | } |
| 1770 | } | 1764 | } |
| 1771 | 1765 | ||