branch: externals/pyim commit 504f20fd49ec8171c9242028bb578b3b79bdd4f4 Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
cl-defgeneric pyim-dcache-insert-word --- pyim-dcache.el | 10 ++-------- pyim-dhashcache.el | 14 ++++++++++++++ pyim-dregcache.el | 6 ++++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/pyim-dcache.el b/pyim-dcache.el index 93f5c520ef..b895774e15 100644 --- a/pyim-dcache.el +++ b/pyim-dcache.el @@ -239,17 +239,11 @@ non-nil,文件存在时将会提示用户是否覆盖,默认为覆盖模式" (pyim-dcache-call-api 'update-iword2count word wordcount-handler)) ;; ** Dcache 加词功能 -(defun pyim-dcache-insert-word (word code prepend) +(cl-defgeneric 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 prepend)) +内部函数会根据 CODE 来确定插入对应的 hash key.") ;; ** Dcache 升级功能 (cl-defgeneric pyim-dcache-upgrade () diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el index 3e4c13388f..3ce3775f52 100644 --- a/pyim-dhashcache.el +++ b/pyim-dhashcache.el @@ -664,6 +664,20 @@ code 对应的中文词条了。 (remhash word pyim-dhashcache-iword2count-log) (remhash word pyim-dhashcache-iword2priority)) +(cl-defmethod pyim-dcache-insert-word + (word code prepend + &context (pyim-dcache-backend (eql pyim-dhashcache))) + "将词条 WORD 插入到下面两个词库缓存中。 + +1. `pyim-dhashcache-icode2word' +2. `pyim-dhashcache-insert-word-into-ishortcode2word'." + (pyim-dhashcache-insert-word-into-icode2word word code prepend) + ;; NOTE: 保存词条到 icode2word 词库缓存的同时,也在 ishortcode2word 词库缓存中 + ;; 临时写入一份,供当前 Emacs session 使用,但退出时 pyim 不会保存 + ;; ishortcode2word 词库缓存到文件,因为下次启动 Emacs 的时候,ishortcode2word + ;; 词库缓存会从 icode2word 再次重建。 + (pyim-dhashcache-insert-word-into-ishortcode2word word code prepend)) + (defun pyim-dhashcache-insert-word-into-icode2word (word code prepend) "将词条 WORD 插入到 icode2word 词库缓存 CODE 键对应的位置. diff --git a/pyim-dregcache.el b/pyim-dregcache.el index 6ce1e17256..2c09913e3e 100644 --- a/pyim-dregcache.el +++ b/pyim-dregcache.el @@ -397,6 +397,12 @@ DICT-FILES 是词库文件列表. DICTS-MD5 是词库的MD5校验码. ;; 删除对应词条的词频 (remhash word pyim-dregcache-iword2count)) +(cl-defmethod pyim-dcache-insert-word + (word code prepend + &context (pyim-dcache-backend (eql pyim-dregcache))) + "将词条 WORD 插入到 `pyim-dregcache-icode2word'." + (pyim-dregcache-insert-word-into-icode2word word code prepend)) + (defun pyim-dregcache-insert-word-into-icode2word (word code prepend) "保存个人词到缓存,和其他词库格式一样以共享正则搜索算法." (when pyim-debug