emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/pyim 403c579330 1/2: Fix no-record error in Emacs 25 an


From: ELPA Syncer
Subject: [elpa] externals/pyim 403c579330 1/2: Fix no-record error in Emacs 25 and 26.
Date: Thu, 23 Jun 2022 01:57:56 -0400 (EDT)

branch: externals/pyim
commit 403c57933059683ebf232ba5470cd6d63fea895e
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>

    Fix no-record error in Emacs 25 and 26.
---
 pyim-common.el      | 16 +++++++++++++---
 tests/pyim-tests.el | 52 ++++++++++++++++++++++++++++++++++------------------
 2 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/pyim-common.el b/pyim-common.el
index 9c8047330f..7658583e4c 100644
--- a/pyim-common.el
+++ b/pyim-common.el
@@ -191,9 +191,19 @@ When CARE-FIRST-ONE is no-nil, ((a b c) (d e)) => (a d)."
     (setq unread-command-events nil))
   (setq unread-command-events
         (if (characterp key)
-            (cons (cons 'no-record key) unread-command-events)
-          (append (cl-mapcan (lambda (e) (list (cons 'no-record e)))
-                             (append key nil))
+            ;; Emacs >= 27 support (no-record . EVENT), please read emacs
+            ;; commit: f13d97b4de02586cce49909aa2f3f51fcb5daa5f (Fix defining
+            ;; keyboard macros in CUA mode)
+            (cons (if (> emacs-major-version 26)
+                      (cons 'no-record key)
+                    key)
+                  unread-command-events)
+          (append (cl-mapcan
+                   (lambda (e)
+                     (list (if (> emacs-major-version 26)
+                               (cons 'no-record e)
+                             e)))
+                   (append key nil))
                   unread-command-events))))
 
 ;; Fork from `company-dabbrev--time-limit-while' in company-mode."
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 42791a150d..e055b75f71 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -210,24 +210,40 @@
 
 (ert-deftest pyim-tests-pyim-add-unread-command-events ()
   (let ((unread-command-events nil))
-    (pyim-add-unread-command-events ?a)
-    (should (equal unread-command-events
-                   '((no-record . 97))))
-    (pyim-add-unread-command-events "b")
-    (should (equal unread-command-events
-                   '((no-record . 98)
-                     (no-record . 97))))
-    (pyim-add-unread-command-events "cd")
-    (should (equal unread-command-events
-                   '((no-record . 99)
-                     (no-record . 100)
-                     (no-record . 98)
-                     (no-record . 97))))
-    (pyim-add-unread-command-events "e" t)
-    (should (equal unread-command-events
-                   '((no-record . 101))))
-    (pyim-add-unread-command-events nil t)
-    (should (equal unread-command-events nil))))
+    (if (> emacs-major-version 26)
+        (progn
+          (pyim-add-unread-command-events ?a)
+          (should (equal unread-command-events
+                         '((no-record . 97))))
+          (pyim-add-unread-command-events "b")
+          (should (equal unread-command-events
+                         '((no-record . 98)
+                           (no-record . 97))))
+          (pyim-add-unread-command-events "cd")
+          (should (equal unread-command-events
+                         '((no-record . 99)
+                           (no-record . 100)
+                           (no-record . 98)
+                           (no-record . 97))))
+          (pyim-add-unread-command-events "e" t)
+          (should (equal unread-command-events
+                         '((no-record . 101))))
+          (pyim-add-unread-command-events nil t)
+          (should (equal unread-command-events nil)))
+      (pyim-add-unread-command-events ?a)
+      (should (equal unread-command-events
+                     '(97)))
+      (pyim-add-unread-command-events "b")
+      (should (equal unread-command-events
+                     '(98 97)))
+      (pyim-add-unread-command-events "cd")
+      (should (equal unread-command-events
+                     '(99 100 98 97)))
+      (pyim-add-unread-command-events "e" t)
+      (should (equal unread-command-events
+                     '(101)))
+      (pyim-add-unread-command-events nil t)
+      (should (equal unread-command-events nil)))))
 
 (ert-deftest pyim-tests-pyim-time-limit-while ()
   (let ((time (current-time))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]