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

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

[elpa] externals/pyim 7af7eb0a95: pyim-dcache do not depend pyim-dict


From: ELPA Syncer
Subject: [elpa] externals/pyim 7af7eb0a95: pyim-dcache do not depend pyim-dict
Date: Mon, 18 Apr 2022 02:57:46 -0400 (EDT)

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

    pyim-dcache do not depend pyim-dict
    
        * pyim.el (pyim-dict): Require.
    
            * pyim-dregcache.el (pyim-dict): Require.
            (pyim-dregcache-update): New function.
    
            * pyim-dhashcache.el (pyim-dict): Require.
            (pyim-dhashcache-update): New function.
    
            * pyim-dcache.el (pyim-dict): Do not require.
            (pyim-dcache-auto-update): Update.
            (pyim-dcache-update): Use pyim-dcache-call-api.
            (pyim-dcache-create-files-md5): Rename from 
pyim-dcache-create-dicts-md5.
---
 pyim-dcache.el     | 26 ++++++++------------------
 pyim-dhashcache.el | 16 ++++++++++++++++
 pyim-dregcache.el  | 16 ++++++++++++++++
 pyim.el            |  1 +
 4 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/pyim-dcache.el b/pyim-dcache.el
index 343af278b4..96e515a18b 100644
--- a/pyim-dcache.el
+++ b/pyim-dcache.el
@@ -29,7 +29,6 @@
 ;; * 代码                                                           :code:
 (require 'cl-lib)
 (require 'pyim-common)
-(require 'pyim-dict)
 (require 'url-util)
 
 (defgroup pyim-dcache nil
@@ -55,8 +54,8 @@
 (defvar pyim-dcache-auto-update t
   "是否自动创建和更新词库对应的 dcache 文件.
 
-这个变量默认设置为 t, 如果有词库文件添加到 `pyim-dicts' 或者
-`pyim-extra-dicts' 时,pyim 会自动生成相关的 dcache 文件。
+这个变量默认设置为 t, 用户添加新的词库文件时,pyim 会自动生成相关
+的 dcache 文件。
 
 一般不建议将这个变量设置为 nil,除非有以下情况:
 
@@ -218,25 +217,16 @@ non-nil,文件存在时将会提示用户是否覆盖,默认为覆盖模式"
   "读取并加载所有相关词库 dcache.
 
 如果 FORCE 为真,强制加载。"
-  (pyim-dcache-init-variables)
-  (when pyim-dcache-auto-update
-    (pyim-dcache-call-api 'update-iword2priority force)
-    (pyim-dcache-call-api 'update-personal-words force)
-    (let* ((dict-files (mapcar (lambda (x)
-                                 (unless (plist-get x :disable)
-                                   (plist-get x :file)))
-                               `(,@pyim-dicts ,@pyim-extra-dicts)))
-           (dicts-md5 (pyim-dcache-create-dicts-md5 dict-files)))
-      (pyim-dcache-call-api 'update-code2word dict-files dicts-md5 force))))
-
-(defun pyim-dcache-create-dicts-md5 (dict-files)
-  "为 DICT-FILES 生成 md5 字符串。"
-  ;;当需要强制更新 dict 缓存时,更改这个字符串。
+  (pyim-dcache-call-api 'update force))
+
+(defun pyim-dcache-create-files-md5 (files)
+  "为 FILES 生成 md5 字符串。"
+  ;; 当需要强制更新 dict 缓存时,更改这个字符串。
   (let ((version "v1"))
     (md5 (prin1-to-string
           (mapcar (lambda (file)
                     (list version file (nth 5 (file-attributes file 'string))))
-                  dict-files)))))
+                  files)))))
 
 (defun pyim-dcache-update-wordcount (word &optional wordcount-handler)
   "保存 WORD 词频.
diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index 56df6622e2..1b3a3bd1f3 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -38,6 +38,7 @@
 (require 'pyim-common)
 (require 'pyim-pymap)
 (require 'pyim-dcache)
+(require 'pyim-dict)
 (require 'pyim-scheme)
 
 (defvar pyim-dhashcache-count-types
@@ -79,6 +80,21 @@
 (defvar pyim-dhashcache-update-iword2priority-p nil)
 (defvar pyim-dhashcache-update-code2word-running-p nil)
 
+(defun pyim-dhashcache-update (&optional force)
+  "读取并加载所有相关词库 dcache.
+
+如果 FORCE 为真,强制加载。"
+  (pyim-dcache-init-variables)
+  (when pyim-dcache-auto-update
+    (pyim-dcache-call-api 'update-iword2priority force)
+    (pyim-dcache-call-api 'update-personal-words force)
+    (let* ((dict-files (mapcar (lambda (x)
+                                 (unless (plist-get x :disable)
+                                   (plist-get x :file)))
+                               `(,@pyim-dicts ,@pyim-extra-dicts)))
+           (dicts-md5 (pyim-dcache-create-files-md5 dict-files)))
+      (pyim-dcache-call-api 'update-code2word dict-files dicts-md5 force))))
+
 (defun pyim-dhashcache-sort-words (words-list)
   "对 WORDS-LIST 排序"
   (let ((iword2count pyim-dhashcache-iword2count)
diff --git a/pyim-dregcache.el b/pyim-dregcache.el
index 94c7764cdf..f7523f2977 100644
--- a/pyim-dregcache.el
+++ b/pyim-dregcache.el
@@ -35,6 +35,7 @@
 ;;; Code:
 ;; * 代码                                                                 :code:
 (require 'pyim-common)
+(require 'pyim-dict)
 (require 'subr-x)
 
 (defvar pyim-dregcache-partition-minimum-size 32
@@ -45,6 +46,21 @@
 (defvar pyim-dregcache-iword2count nil)
 (defvar pyim-dregcache-dicts-md5 nil)
 
+(defun pyim-dregcache-update (&optional force)
+  "读取并加载所有相关词库 dcache.
+
+如果 FORCE 为真,强制加载。"
+  (pyim-dcache-init-variables)
+  (when pyim-dcache-auto-update
+    (pyim-dcache-call-api 'update-iword2priority force)
+    (pyim-dcache-call-api 'update-personal-words force)
+    (let* ((dict-files (mapcar (lambda (x)
+                                 (unless (plist-get x :disable)
+                                   (plist-get x :file)))
+                               `(,@pyim-dicts ,@pyim-extra-dicts)))
+           (dicts-md5 (pyim-dcache-create-files-md5 dict-files)))
+      (pyim-dcache-call-api 'update-code2word dict-files dicts-md5 force))))
+
 (defun pyim-dregcache-variable-file (variable)
   "Get VARIABLE dcache file path."
   (concat (file-name-as-directory pyim-dcache-directory)
diff --git a/pyim.el b/pyim.el
index e314339763..f66edc71d6 100644
--- a/pyim.el
+++ b/pyim.el
@@ -42,6 +42,7 @@
 (require 'pyim-indicator)
 (require 'pyim-process)
 (require 'pyim-cstring)
+(require 'pyim-dict)
 
 (defgroup pyim nil
   "Pyim is a Chinese input method support quanpin, shuangpin, wubi and 
cangjie."



reply via email to

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