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 /test/src/keymap-tests.el | |
| 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 'test/src/keymap-tests.el')
| -rw-r--r-- | test/src/keymap-tests.el | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el index c605c3eb09d..950c741a6dd 100644 --- a/test/src/keymap-tests.el +++ b/test/src/keymap-tests.el | |||
| @@ -509,6 +509,33 @@ g .. h foo | |||
| 509 | ;; From the parent this time/ | 509 | ;; From the parent this time/ |
| 510 | (should (equal (keymap-lookup map "u") #'undo)))) | 510 | (should (equal (keymap-lookup map "u") #'undo)))) |
| 511 | 511 | ||
| 512 | (defun keymap-test--maps-for-posn (area string) | ||
| 513 | (current-active-maps | ||
| 514 | nil | ||
| 515 | ;; FIXME: This test would be better if this was a real position | ||
| 516 | ;; created by a real click. | ||
| 517 | `(,(selected-window) ,area (1 . 1) 0 (,string . 0) nil (1 . 1) nil (1 . 1) (1 . 1)))) | ||
| 518 | |||
| 519 | (ert-deftest keymap-test-keymaps-for-non-buffer-positions () | ||
| 520 | "`current-active-maps' with non-buffer positions. (bug#76620)" | ||
| 521 | (with-temp-buffer | ||
| 522 | (pop-to-buffer (current-buffer)) | ||
| 523 | (let ((keymap (make-sparse-keymap "keymap-at-point"))) | ||
| 524 | (insert (propertize "string" 'keymap keymap)) | ||
| 525 | (goto-char (point-min)) | ||
| 526 | (should (memq keymap (current-active-maps))) | ||
| 527 | (should-not (memq keymap (keymap-test--maps-for-posn 'mode-line nil))) | ||
| 528 | (should-not (memq keymap (keymap-test--maps-for-posn 'mode-line "s"))) | ||
| 529 | (should-not (memq keymap (keymap-test--maps-for-posn nil "s"))) | ||
| 530 | (should (memq keymap (keymap-test--maps-for-posn nil nil))) | ||
| 531 | (let* ((mode-line-keymap (make-sparse-keymap "keymap-in-mode-line")) | ||
| 532 | (s (propertize "string" 'keymap mode-line-keymap))) | ||
| 533 | ;; Respect `keymap' in the string clicked on. | ||
| 534 | (should-not (memq keymap (keymap-test--maps-for-posn nil s))) | ||
| 535 | (should-not (memq keymap (keymap-test--maps-for-posn 'mode-line s))) | ||
| 536 | (should (memq mode-line-keymap (keymap-test--maps-for-posn nil s))) | ||
| 537 | (should (memq mode-line-keymap (keymap-test--maps-for-posn 'mode-line s))))))) | ||
| 538 | |||
| 512 | (provide 'keymap-tests) | 539 | (provide 'keymap-tests) |
| 513 | 540 | ||
| 514 | ;;; keymap-tests.el ends here | 541 | ;;; keymap-tests.el ends here |