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

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

[elpa] externals/pyim d504e40713: Add pyim-dict-get-enabled-dict-files


From: ELPA Syncer
Subject: [elpa] externals/pyim d504e40713: Add pyim-dict-get-enabled-dict-files
Date: Mon, 30 May 2022 23:57:54 -0400 (EDT)

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

    Add pyim-dict-get-enabled-dict-files
    
            * pyim-dregcache.el (pyim-dregcache-update-code2word): Update 
docstring.
    
            * tests/pyim-tests.el (pyim-tests-pyim-extra-dicts-add-dict): 
Update.
    
            * pyim-dregcache.el (pyim-dregcache-update): Use 
pyim-dict-get-enabled-dict-files.
    
            * pyim-dict.el (pyim-dict-get-enabled-dict-files): New function.
    
            * pyim-dhashcache.el (pyim-dhashcache-update): 
pyim-dict-get-enabled-dict-files.
            * pyim-dregcache.el (pyim-dhashcache-update-code2word): Update 
docstring.
---
 pyim-dhashcache.el  |  8 ++------
 pyim-dict.el        |  8 ++++++++
 pyim-dregcache.el   |  8 ++------
 tests/pyim-tests.el | 10 +++++++---
 4 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index de82a50656..ee3fb98dd3 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -87,10 +87,7 @@
   (when pyim-dcache-auto-update
     (pyim-dhashcache-update-iword2priority force)
     (pyim-dhashcache-update-personal-words force)
-    (let* ((dict-files (mapcar (lambda (x)
-                                 (unless (plist-get x :disable)
-                                   (plist-get x :file)))
-                               `(,@pyim-dicts ,@pyim-extra-dicts)))
+    (let* ((dict-files (pyim-dict-get-enabled-dict-files))
            (dicts-md5 (pyim-dcache-create-files-md5 dict-files)))
       (pyim-dhashcache-update-code2word dict-files dicts-md5 force))))
 
@@ -341,8 +338,7 @@ DCACHE 是一个 code -> words 的 hashtable.
 (defun pyim-dhashcache-update-code2word (dict-files dicts-md5 &optional force)
   "读取并加载词库.
 
-读取 `pyim-dicts' 和 `pyim-extra-dicts' 里面的词库文件,生成对应的
-词库缓冲文件,然后加载词库缓存。
+读取词库文件 DICT-FILES,生成对应的词库缓冲文件,然后加载词库缓存。
 
 如果 FORCE 为真,强制加载。"
   (interactive)
diff --git a/pyim-dict.el b/pyim-dict.el
index 1bdb16c471..7bf544dcd8 100644
--- a/pyim-dict.el
+++ b/pyim-dict.el
@@ -76,6 +76,14 @@ plist 来表示,比如:
     (message "PYIM: Add dict %S to `pyim-extra-dicts'." (plist-get new-dict 
:name))
     t))
 
+(defun pyim-dict-get-enabled-dict-files ()
+  "获取所有已经启用的 dict 文件。"
+  (delete nil
+          (mapcar (lambda (x)
+                    (unless (plist-get x :disable)
+                      (plist-get x :file)))
+                  `(,@pyim-dicts ,@pyim-extra-dicts))))
+
 ;; * Footer
 (provide 'pyim-dict)
 
diff --git a/pyim-dregcache.el b/pyim-dregcache.el
index c63f4f03b7..4686b074ed 100644
--- a/pyim-dregcache.el
+++ b/pyim-dregcache.el
@@ -51,10 +51,7 @@
   (pyim-dregcache-init-variables)
   (when pyim-dcache-auto-update
     (pyim-dregcache-update-personal-words force)
-    (let* ((dict-files (mapcar (lambda (x)
-                                 (unless (plist-get x :disable)
-                                   (plist-get x :file)))
-                               `(,@pyim-dicts ,@pyim-extra-dicts)))
+    (let* ((dict-files (pyim-dict-get-enabled-dict-files))
            (dicts-md5 (pyim-dcache-create-files-md5 dict-files)))
       (when pyim-debug
         (message "pyim-dregcache-update: pyim-dicts=%s pyim-extra-dicts=%s 
dict-files=%s"
@@ -153,8 +150,7 @@
 (defun pyim-dregcache-update-code2word (dict-files dicts-md5 &optional force)
   "读取并加载词库.
 
-读取 `pyim-dicts' 和 `pyim-extra-dicts' 里面的词库文件,生成对应的
-词库缓冲文件,然后加载词库缓存。
+读取词库文件 DICT-FILES,生成对应的词库缓冲文件,然后加载词库缓存。
 
 DICT-FILES 是词库文件列表. DICTS-MD5 是词库的MD5校验码.
 
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index f92cfdea05..82ed76af8b 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -768,17 +768,21 @@ ni-hao 你好 尼耗
 ")))))
 
 ;; ** pyim-dict 相关单元测试
-(ert-deftest pyim-tests-pyim-extra-dicts-add-dict ()
+(ert-deftest pyim-tests-pyim-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")))
+        (dict3 '(:name "test1" :file "/home/user/test3.pyim"))
+        (dict4 '(:name "test4" :file "/home/user/test4.pyim" :disable t)))
     (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)))))
+    (should (equal pyim-extra-dicts `(,dict3 ,dict2)))
+    (pyim-extra-dicts-add-dict dict4)
+    (should (equal (pyim-dict-get-enabled-dict-files)
+                   '("/home/user/test3.pyim" "/home/user/test2.pyim")))))
 
 ;; ** pyim-dhashcache 相关单元测试
 (ert-deftest pyim-tests-pyim-dhashcache-get-shortcodes ()



reply via email to

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