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

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

[elpa] externals/pyim ed178db3a0 2/2: Improve pyim-extra-dicts-add-dict.


From: ELPA Syncer
Subject: [elpa] externals/pyim ed178db3a0 2/2: Improve pyim-extra-dicts-add-dict.
Date: Mon, 30 May 2022 18:57:47 -0400 (EDT)

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

    Improve pyim-extra-dicts-add-dict.
    
            * tests/pyim-tests.el (pyim-tests-pyim-extra-dicts-add-dict): New 
test.
    
            * pyim-dict.el (pyim-extra-dicts-add-dict): Improve.
---
 pyim-dict.el        | 10 ++++++----
 tests/pyim-tests.el | 13 +++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/pyim-dict.el b/pyim-dict.el
index 9590d9ffa1..1bdb16c471 100644
--- a/pyim-dict.el
+++ b/pyim-dict.el
@@ -54,13 +54,13 @@ plist 来表示,比如:
 不建议用户手工设置这个变量。")
 
 (defun pyim-extra-dicts-add-dict (new-dict)
-  "添加 `new-dict' 到 `pyim-extra-dicts'.
+  "将 NEW-DICT 添加到 `pyim-extra-dicts'.
 
 其中 NEW-DICT 的格式为:
 
    (:name \"XXX\" :file \"/path/to/XXX.pyim\")
 
-这个函数用于制作 elpa 格式的词库 ,不建议普通用户使用。"
+这个函数主要用于 elpa 词库包 ,不建议普通用户使用。"
   (let (replace result)
     (dolist (dict pyim-extra-dicts)
       (if (equal (plist-get dict :name)
@@ -70,8 +70,10 @@ plist 来表示,比如:
         (push dict result)))
     (setq result (reverse result))
     (setq pyim-extra-dicts
-          (if replace result `(,@result ,new-dict)))
-    (message "Add pyim dict %S to `pyim-extra-dicts'." (plist-get new-dict 
:name))
+          (if replace
+              result
+            `(,@result ,new-dict)))
+    (message "PYIM: Add dict %S to `pyim-extra-dicts'." (plist-get new-dict 
:name))
     t))
 
 ;; * Footer
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index b4f07ad6ac..f92cfdea05 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -767,6 +767,19 @@
 ni-hao 你好 尼耗
 ")))))
 
+;; ** pyim-dict 相关单元测试
+(ert-deftest pyim-tests-pyim-extra-dicts-add-dict ()
+  (let ((pyim-extra-dicts nil)
+        (dict1 '(:name "test1" :file "/home/user/test1.pyim"))
+        (dict2 '(:name "test2" :file "/home/user/test2.pyim"))
+        (dict3 '(:name "test1" :file "/home/user/test3.pyim")))
+    (pyim-extra-dicts-add-dict dict1)
+    (should (equal pyim-extra-dicts `(,dict1)))
+    (pyim-extra-dicts-add-dict dict2)
+    (should (equal pyim-extra-dicts `(,dict1 ,dict2)))
+    (pyim-extra-dicts-add-dict dict3)
+    (should (equal pyim-extra-dicts `(,dict3 ,dict2)))))
+
 ;; ** pyim-dhashcache 相关单元测试
 (ert-deftest pyim-tests-pyim-dhashcache-get-shortcodes ()
   (should (equal (pyim-dhashcache-get-shortcodes ".abcde") nil))



reply via email to

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