branch: externals/pyim commit 64d43a9a52d85c1cb17e65ec28adf37414b01c32 Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
cl-defgeneric pyim-dcache-delete-word --- pyim-dcache.el | 5 ++--- pyim-dhashcache.el | 3 ++- pyim-dregcache.el | 3 ++- tests/pyim-tests.el | 7 ++++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pyim-dcache.el b/pyim-dcache.el index c0a2cba356..22cf9fcf02 100644 --- a/pyim-dcache.el +++ b/pyim-dcache.el @@ -261,9 +261,8 @@ non-nil,文件存在时将会提示用户是否覆盖,默认为覆盖模式" (pyim-dcache-call-api 'upgrade-icode2word)) ;; ** Dcache 删词功能 -(defun pyim-dcache-delete-word (word) - "将中文词条 WORD 从个人词库中删除" - (pyim-dcache-call-api 'delete-word word)) +(cl-defgeneric pyim-dcache-delete-word (word) + "将中文词条 WORD 从个人词库中删除") ;; ** Dcache 检索功能 (cl-defgeneric pyim-dcache-get (code &optional from) diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el index c4e242cc64..ddaa04f26b 100644 --- a/pyim-dhashcache.el +++ b/pyim-dhashcache.el @@ -633,7 +633,8 @@ code 对应的中文词条了。 (lambda (_) (pyim-dcache-reload-variable pyim-dhashcache-iword2priority))))) -(defun pyim-dhashcache-delete-word (word) +(cl-defmethod pyim-dcache-delete-word + (word &context (pyim-dcache-backend (eql pyim-dhashcache))) "将中文词条 WORD 从个人词库中删除" (maphash (lambda (key value) diff --git a/pyim-dregcache.el b/pyim-dregcache.el index 909ae51584..9133e9b015 100644 --- a/pyim-dregcache.el +++ b/pyim-dregcache.el @@ -372,7 +372,8 @@ DICT-FILES 是词库文件列表. DICTS-MD5 是词库的MD5校验码. (unless (equal orig-value new-value) (puthash word new-value pyim-dregcache-iword2count)))) -(defun pyim-dregcache-delete-word (word) +(cl-defmethod pyim-dcache-delete-word + (word &context (pyim-dcache-backend (eql pyim-dregcache))) "将中文词条 WORD 从个人词库中删除." (with-temp-buffer (insert pyim-dregcache-icode2word) diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el index 10dc88391f..0e339e5d07 100644 --- a/tests/pyim-tests.el +++ b/tests/pyim-tests.el @@ -1125,7 +1125,8 @@ zuo-zuo-you-mang 作作有芒") '("你" "呢"))))) (ert-deftest pyim-tests-pyim-dhashcache-put/delete () - (let ((pyim-dhashcache-icode2word (make-hash-table :test #'equal))) + (let ((pyim-dcache-backend 'pyim-dhashcache) + (pyim-dhashcache-icode2word (make-hash-table :test #'equal))) (puthash "ni-hao" '("你好" "呢耗") pyim-dhashcache-icode2word) (pyim-dhashcache-put pyim-dhashcache-icode2word "ni-hao" @@ -1135,9 +1136,9 @@ zuo-zuo-you-mang 作作有芒") (list "你不好")) (should (equal (gethash "ni-hao" pyim-dhashcache-icode2word) '("呢毫" "你好" "呢耗"))) (should (equal (gethash "ni-bu-hao" pyim-dhashcache-icode2word) '("你不好"))) - (pyim-dhashcache-delete-word "你不好") + (pyim-dcache-delete-word "你不好") (should (equal (gethash "ni-bu-hao" pyim-dhashcache-icode2word) nil)) - (pyim-dhashcache-delete-word "你好") + (pyim-dcache-delete-word "你好") (should (equal (gethash "ni-hao" pyim-dhashcache-icode2word) '("呢毫" "呢耗"))))) (ert-deftest pyim-tests-pyim-dhashcache-update-iword2count ()