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

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

[elpa] externals/pyim e4a76ac 1/2: 更好的处理拼音输入法的 ishortcode2word 词库缓存


From: ELPA Syncer
Subject: [elpa] externals/pyim e4a76ac 1/2: 更好的处理拼音输入法的 ishortcode2word 词库缓存
Date: Mon, 6 Dec 2021 04:57:27 -0500 (EST)

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

    更好的处理拼音输入法的 ishortcode2word 词库缓存
    
    保存词条到 icode2word 词库缓存的同时,也在 ishortcode2word 词库缓存中临时写入一
    份,供当前 Emacs session 使用,但退出时 pyim 不会保存ishortcode2word 词库缓存到
    文件,因为下次启动 Emacs 的时候,ishortcode2word词库缓存会从 icode2word 再次重建。
---
 pyim-dhashcache.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index 3379caa..76e537b 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -416,7 +416,20 @@ code 对应的中文词条了。
     pyim-dhashcache-icode2word pinyin
     (if prepend
         `(,word ,@(remove word orig-value))
-      `(,@(remove word orig-value) ,word))))
+      `(,@(remove word orig-value) ,word)))
+  ;; NOTE: 保存词条到 icode2word 词库缓存的同时,也在 ishortcode2word 词库缓存中
+  ;; 临时写入一份,供当前 Emacs session 使用,但退出时 pyim 不会保存
+  ;; ishortcode2word 词库缓存到文件,因为下次启动 Emacs 的时候,ishortcode2word
+  ;; 词库缓存会从 icode2word 再次重建。
+  (when (string-match-p "-" pinyin)
+    (pyim-dhashcache-put
+      pyim-dhashcache-ishortcode2word
+      ;; ni-hao -> n-h
+      (mapconcat (lambda (x)
+                   (char-to-string (elt x 0)))
+                 (split-string pinyin "-")
+                 "-")
+      `(,word ,@(remove word orig-value)))))
 
 (defun pyim-dhashcache-search-word-code (string)
   (gethash string pyim-dhashcache-word2code))



reply via email to

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