[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 013ed27: 调整 ishortcode2word 插入词条的相关代码。
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 013ed27: 调整 ishortcode2word 插入词条的相关代码。 |
Date: |
Mon, 6 Dec 2021 17:57:32 -0500 (EST) |
branch: externals/pyim
commit 013ed27705c8bf67a90463d8502d5547d885fd94
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
调整 ishortcode2word 插入词条的相关代码。
* pyim-process.el (pyim-process-create-word): Use
pyim-dcache-insert-word.
* pyim-dhashcache.el (pyim-dhashcache-insert-word-into-icode2word):
split ...
(pyim-dhashcache-insert-word-into-ishortcode2word): to ...
* pyim-dcache.el (pyim-dcache-insert-word): Rename from
pyim-dcache-insert-icode2word.
---
pyim-dcache.el | 14 +++++++++++---
pyim-dhashcache.el | 24 +++++++++++++-----------
pyim-process.el | 2 +-
3 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/pyim-dcache.el b/pyim-dcache.el
index 14a4351..38dd139 100644
--- a/pyim-dcache.el
+++ b/pyim-dcache.el
@@ -256,9 +256,17 @@ non-nil,文件存在时将会提示用户是否覆盖,默认为覆盖模式"
(pyim-dcache-call-api 'search-word-code word))
;; ** Dcache 加词功能
-(defun pyim-dcache-insert-icode2word (word pinyin prepend)
- "保存个人词到缓存."
- (pyim-dcache-call-api 'insert-word-into-icode2word word pinyin prepend))
+(defun pyim-dcache-insert-word (word code prepend)
+ "将词条 WORD 插入到 dcache 中。
+
+如果 PREPEND 为 non-nil, 词条将放到已有词条的最前面。
+内部函数会根据 CODE 来确定插入对应的 hash key."
+ (pyim-dcache-call-api 'insert-word-into-icode2word word code prepend)
+ ;; NOTE: 保存词条到 icode2word 词库缓存的同时,也在 ishortcode2word 词库缓存中
+ ;; 临时写入一份,供当前 Emacs session 使用,但退出时 pyim 不会保存
+ ;; ishortcode2word 词库缓存到文件,因为下次启动 Emacs 的时候,ishortcode2word
+ ;; 词库缓存会从 icode2word 再次重建。
+ (pyim-dcache-call-api 'insert-word-into-ishortcode2word word code))
;; ** Dcache 升级功能
(defun pyim-dcache-upgrade-icode2word ()
diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index 76e537b..f108deb 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -410,24 +410,26 @@ code 对应的中文词条了。
pyim-dhashcache-icode2word)
(remhash word pyim-dhashcache-iword2count))
-(defun pyim-dhashcache-insert-word-into-icode2word (word pinyin prepend)
- "保存个人词到缓存."
+(defun pyim-dhashcache-insert-word-into-icode2word (word code prepend)
+ "将词条 WORD 插入到 icode2word 词库缓存 CODE 键对应的位置.
+
+默认 WORD 放到已有词条的最后,如果 PREPEND 为 non-nil, WORD 将放
+到已有词条的最前面。"
(pyim-dhashcache-put
- pyim-dhashcache-icode2word pinyin
+ pyim-dhashcache-icode2word code
(if prepend
`(,word ,@(remove word orig-value))
- `(,@(remove word orig-value) ,word)))
- ;; NOTE: 保存词条到 icode2word 词库缓存的同时,也在 ishortcode2word 词库缓存中
- ;; 临时写入一份,供当前 Emacs session 使用,但退出时 pyim 不会保存
- ;; ishortcode2word 词库缓存到文件,因为下次启动 Emacs 的时候,ishortcode2word
- ;; 词库缓存会从 icode2word 再次重建。
- (when (string-match-p "-" pinyin)
+ `(,@(remove word orig-value) ,word))))
+
+(defun pyim-dhashcache-insert-word-into-ishortcode2word (word code)
+ "将词条 WORD 插入到 ishortcode2word 词库缓存 CODE 首字母字符串对应的位置."
+ (when (string-match-p "-" code)
(pyim-dhashcache-put
pyim-dhashcache-ishortcode2word
;; ni-hao -> n-h
(mapconcat (lambda (x)
- (char-to-string (elt x 0)))
- (split-string pinyin "-")
+ (substring x 0 1))
+ (split-string code "-")
"-")
`(,word ,@(remove word orig-value)))))
diff --git a/pyim-process.el b/pyim-process.el
index 98e673c..70c0f6e 100644
--- a/pyim-process.el
+++ b/pyim-process.el
@@ -548,7 +548,7 @@ BUG:拼音无法有效地处理多音字。"
;; 添加词条到个人缓存
(dolist (code codes)
(unless (pyim-string-match-p "[^ a-z-]" code)
- (pyim-dcache-insert-icode2word
+ (pyim-dcache-insert-word
(if (and (> (length word) 1)
(> (length codes) 1))
;; 如果 word 超过一个汉字,并且得到多个 codes,那么大概率说明没有
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/pyim 013ed27: 调整 ishortcode2word 插入词条的相关代码。,
ELPA Syncer <=