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

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

[elpa] externals/pyim a66e999 2/2: Add variable: pyim-dhashcache-update-


From: ELPA Syncer
Subject: [elpa] externals/pyim a66e999 2/2: Add variable: pyim-dhashcache-update-code2word-running-p
Date: Tue, 16 Nov 2021 21:57:26 -0500 (EST)

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

    Add variable: pyim-dhashcache-update-code2word-running-p
    
        * pyim-dhashcache.el (pyim-dhashcache-update-code2word-running-p): New 
variable.
        (pyim-dhashcache-update-code2word): Use 
pyim-dhashcache-update-code2word-running-p.
---
 pyim-dhashcache.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index a2cb463..b402bba 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -51,6 +51,7 @@
 (defvar pyim-dhashcache-update-shortcode2word nil)
 (defvar pyim-dhashcache-update-ishortcode2word nil)
 (defvar pyim-dhashcache-update-icode2word-p nil)
+(defvar pyim-dhashcache-update-code2word-running-p nil)
 
 (defun pyim-dhashcache-sort-words (words-list)
   "对 WORDS-LIST 排序,词频大的排在前面.
@@ -233,7 +234,9 @@ DCACHE 是一个 code -> words 的 hashtable.
   (let* ((code2word-file (pyim-dhashcache-get-path 'pyim-dhashcache-code2word))
          (word2code-file (pyim-dhashcache-get-path 'pyim-dhashcache-word2code))
          (code2word-md5-file (pyim-dhashcache-get-path 
'pyim-dhashcache-code2word-md5)))
-    (when (or force (not (equal dicts-md5 (pyim-dcache-get-value-from-file 
code2word-md5-file))))
+    (when (and (or force (not (equal dicts-md5 
(pyim-dcache-get-value-from-file code2word-md5-file))))
+               (not pyim-dhashcache-update-code2word-running-p))
+      (setq pyim-dhashcache-update-code2word-running-p t)
       ;; use hashtable
       (async-start
        `(lambda ()
@@ -242,9 +245,10 @@ DCACHE 是一个 code -> words 的 hashtable.
           (let ((dcache (pyim-dhashcache-generate-dcache-file ',dict-files 
,code2word-file)))
             (pyim-dhashcache-generate-word2code-dcache-file dcache 
,word2code-file))
           (pyim-dcache-save-value-to-file ',dicts-md5 ,code2word-md5-file))
-       `(lambda (result)
-          (pyim-dcache-set-variable 'pyim-dhashcache-code2word t)
-          (pyim-dcache-set-variable 'pyim-dhashcache-word2code t))))))
+       (lambda (result)
+         (pyim-dcache-set-variable 'pyim-dhashcache-code2word t)
+         (pyim-dcache-set-variable 'pyim-dhashcache-word2code t)
+         (setq pyim-dhashcache-update-code2word-running-p nil))))))
 
 (defun pyim-dhashcache-export (dcache file &optional confirm)
   "将一个 pyim DCACHE 导出为文件 FILE.



reply via email to

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