diff options
| author | Chris Feng | 2017-11-08 00:39:43 +0800 |
|---|---|---|
| committer | Dmitry Gutov | 2018-12-19 18:06:37 +0200 |
| commit | 305aca0a0abbac1011980e6ac9b166bd0dfd6ff0 (patch) | |
| tree | 99ae6ca92fcf5a6773d64041a571dd68efe7960c | |
| parent | 4c6c327d0c66a21416ed1b5e9738b7dd13e739f2 (diff) | |
| download | emacs-305aca0a0abbac1011980e6ac9b166bd0dfd6ff0.tar.gz emacs-305aca0a0abbac1011980e6ac9b166bd0dfd6ff0.zip | |
Backport: Handle unread-command-events consistently (bug#23980)
* src/keyboard.c (read_char): Events put into `unread-command-events'
with the form (t . EVENT) should always have the t stripped when read
out.
* test/src/keyboard-tests.el: New tests for `unread-command-events'.
(cherry picked from commit 1f3f4b1296613b8cdc0632a68fde86e86ddad866)
| -rw-r--r-- | src/keyboard.c | 3 | ||||
| -rw-r--r-- | test/src/keyboard-tests.el | 34 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index dccc6b7f128..d20557b45d7 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2809,6 +2809,9 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2809 | 2809 | ||
| 2810 | if (EQ (c, make_number (-2))) | 2810 | if (EQ (c, make_number (-2))) |
| 2811 | return c; | 2811 | return c; |
| 2812 | |||
| 2813 | if (CONSP (c) && EQ (XCAR (c), Qt)) | ||
| 2814 | c = XCDR (c); | ||
| 2812 | } | 2815 | } |
| 2813 | 2816 | ||
| 2814 | non_reread: | 2817 | non_reread: |
diff --git a/test/src/keyboard-tests.el b/test/src/keyboard-tests.el new file mode 100644 index 00000000000..d2063a38c14 --- /dev/null +++ b/test/src/keyboard-tests.el | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | ;;; keyboard-tests.el --- Tests for keyboard.c -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright 2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This program is free software; you can redistribute it and/or modify | ||
| 6 | ;; it under the terms of the GNU General Public License as published by | ||
| 7 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 8 | ;; (at your option) any later version. | ||
| 9 | |||
| 10 | ;; This program is distributed in the hope that it will be useful, | ||
| 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | ;; GNU General Public License for more details. | ||
| 14 | |||
| 15 | ;; You should have received a copy of the GNU General Public License | ||
| 16 | ;; along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| 17 | |||
| 18 | ;;; Code: | ||
| 19 | |||
| 20 | (require 'ert) | ||
| 21 | |||
| 22 | (ert-deftest keyboard-unread-command-events () | ||
| 23 | "Test `unread-command-events'." | ||
| 24 | (should (equal (progn (push ?\C-a unread-command-events) | ||
| 25 | (read-event nil nil 1)) | ||
| 26 | ?\C-a)) | ||
| 27 | (should (equal (progn (run-with-timer | ||
| 28 | 1 nil | ||
| 29 | (lambda () (push '(t . ?\C-b) unread-command-events))) | ||
| 30 | (read-event nil nil 2)) | ||
| 31 | ?\C-b))) | ||
| 32 | |||
| 33 | (provide 'keyboard-tests) | ||
| 34 | ;;; keyboard-tests.el ends here | ||