branch: externals/pyim commit 13d853d94fb2d415ba98c3dde635279efa87b399 Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
pyim-candidates -> pyim-process-candidates 现在,所有使用 pyim-candidates 变量的代码都已经移动到 pyim-process 了, 所以这个变量也改名并移动到 pyim-process 了。 --- pyim-candidates.el | 14 -------------- pyim-liberime.el | 2 +- pyim-process.el | 55 +++++++++++++++++++++++++++++++++-------------------- pyim.el | 2 +- tests/pyim-tests.el | 16 ++++++++-------- 5 files changed, 44 insertions(+), 45 deletions(-) diff --git a/pyim-candidates.el b/pyim-candidates.el index a5f0b000ac..3f035fddbe 100644 --- a/pyim-candidates.el +++ b/pyim-candidates.el @@ -43,20 +43,6 @@ "启用输入联想词功能." :type 'boolean) -(defvar pyim-candidates nil - "所有备选词条组成的列表.") - -(defvar pyim-candidates-last nil - "上一轮备选词条列表,这个变量主要用于 autoselector 机制.") - -(defvar pyim-candidate-position nil - "当前选择的词条在 `pyim-candidates’ 中的位置. - -细节信息请参考 `pyim-page-refresh' 的 docstring.") - -(pyim-register-local-variables - '(pyim-candidates pyim-candidate-position)) - ;; ** 获取备选词列表 (defun pyim-candidates-sort (candidates) "对 CANDIDATES 进行排序。" diff --git a/pyim-liberime.el b/pyim-liberime.el index dc75849cde..3175e7f04d 100644 --- a/pyim-liberime.el +++ b/pyim-liberime.el @@ -189,7 +189,7 @@ (reverse pyim-liberime-word-log)) ;; 使用 rime 的同时,也附带的优化 quanpin 的词库。 (let ((pyim-default-scheme 'quanpin)) - (if (member (pyim-outcome-get) pyim-candidates) + (if (member (pyim-outcome-get) pyim-process-candidates) (pyim-process-create-word (pyim-outcome-get) t) (pyim-process-create-word (pyim-outcome-get)))) (setq pyim-liberime-code-log nil) diff --git a/pyim-process.el b/pyim-process.el index 10c4f91cb5..f1cae62af5 100644 --- a/pyim-process.el +++ b/pyim-process.el @@ -136,9 +136,22 @@ entered (nihaom) 的第一个候选词。 (defvar pyim-process-stop-daemon-hook nil "Pyim stop daemon hook.") +(defvar pyim-process-candidates nil + "所有备选词条组成的列表.") + +(defvar pyim-process-candidates-last nil + "上一轮备选词条列表,这个变量主要用于 autoselector 机制.") + +(defvar pyim-process-candidate-position nil + "当前选择的词条在 `pyim-candidates’ 中的位置. + +细节信息请参考 `pyim-page-refresh' 的 docstring.") + (pyim-register-local-variables '(pyim-process-input-ascii - pyim-process-translating)) + pyim-process-translating + pyim-process-candidates + pyim-process-candidate-position)) (defun pyim-process-ui-init () "初始化 pyim 相关 UI." @@ -262,11 +275,11 @@ entered (nihaom) 的第一个候选词。 (setq entered-to-translate (pyim-entered-get 'point-before)) (setq pyim-imobjs (pyim-imobjs-create entered-to-translate scheme)) - (setq pyim-candidates + (setq pyim-process-candidates (or (delete-dups (pyim-candidates-create pyim-imobjs scheme)) (list entered-to-translate))) (unless (eq (pyim-process-auto-select) 'auto-select-success) - (setq pyim-candidate-position 1) + (setq pyim-process-candidate-position 1) (pyim-process-ui-refresh) (pyim-process-run-delay))))) @@ -300,9 +313,9 @@ entered (nihaom) 的第一个候选词。 select-current-word) :replace-with)) (candidates (if select-last-word - pyim-candidates-last - pyim-candidates)) - (pyim-candidates + pyim-process-candidates-last + pyim-process-candidates)) + (pyim-process-candidates (if (and str (stringp str)) (list str) candidates))) @@ -380,8 +393,8 @@ entered (nihaom) 的第一个候选词。 (words (pyim-candidates-create-limit-time pyim-imobjs scheme))) (when words - (setq pyim-candidates - (pyim-process-merge-candidates words pyim-candidates)) + (setq pyim-process-candidates + (pyim-process-merge-candidates words pyim-process-candidates)) (pyim-process-ui-refresh)))) (defun pyim-process-merge-candidates (new-candidates old-candidates) @@ -402,24 +415,24 @@ entered (nihaom) 的第一个候选词。 (when (and pyim-process-translating (not (input-pending-p)) (equal (car async-return) pyim-imobjs)) - (setq pyim-candidates - (pyim-process-merge-candidates (cdr async-return) pyim-candidates)) + (setq pyim-process-candidates + (pyim-process-merge-candidates (cdr async-return) pyim-process-candidates)) (pyim-process-ui-refresh))))))) (defun pyim-process-get-candidates () - pyim-candidates) + pyim-process-candidates) (defun pyim-process-get-last-candidates () - pyim-candidates-last) + pyim-process-candidates-last) (defun pyim-process-get-candidate-position () - pyim-candidate-position) + pyim-process-candidate-position) (defun pyim-process-candidates-length () - (length pyim-candidates)) + (length pyim-process-candidates)) (defun pyim-process-set-candidate-position (n) - (setq pyim-candidate-position n)) + (setq pyim-process-candidate-position n)) (defun pyim-process-get-first-imobj () (car pyim-imobjs)) @@ -466,15 +479,15 @@ entered (nihaom) 的第一个候选词。 pyim-outcome-history)) ((eq type 'candidate) (let ((candidate - (nth (1- pyim-candidate-position) - pyim-candidates))) + (nth (1- pyim-process-candidate-position) + pyim-process-candidates))) (push (concat (pyim-outcome-get) candidate) pyim-outcome-history))) ((eq type 'candidate-and-last-char) (let ((candidate - (nth (1- pyim-candidate-position) - pyim-candidates))) + (nth (1- pyim-process-candidate-position) + pyim-process-candidates))) (push (concat (pyim-outcome-get) candidate @@ -707,8 +720,8 @@ BUG:拼音无法有效地处理多音字。" (pyim-entered-erase-buffer) (setq pyim-process-code-criteria nil) (setq pyim-process-force-input-chinese nil) - (setq pyim-candidates nil) - (setq pyim-candidates-last nil) + (setq pyim-process-candidates nil) + (setq pyim-process-candidates-last nil) (pyim-process-run-delay-timer-reset) (pyim-process-ui-hide)) diff --git a/pyim.el b/pyim.el index de2ccc859d..1c881e4fb4 100644 --- a/pyim.el +++ b/pyim.el @@ -315,7 +315,7 @@ REFRESH-COMMON-DCACHE 已经废弃,不要再使用了。" (defun pyim-self-insert-command () "Pyim 默认的 self-insert-command." (interactive "*") - (setq pyim-candidates-last pyim-candidates) + (setq pyim-process-candidates-last pyim-process-candidates) (cond ((pyim-process-input-chinese-p) (pyim-process-with-entered-buffer diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el index 8834b10085..a1c366cffb 100644 --- a/tests/pyim-tests.el +++ b/tests/pyim-tests.el @@ -1530,32 +1530,32 @@ Transfer-Encoding: chunked ;; ** pyim-preview 相关单元测试 (ert-deftest pyim-tests-pyim-preview-string () - (let ((pyim-candidates '("世界" "时节" "使节" "视界" )) - (pyim-candidate-position 1) + (let ((pyim-process-candidates '("世界" "时节" "使节" "视界" )) + (pyim-process-candidate-position 1) (pyim-outcome-history '("你好")) (pyim-imobjs '((("sh" "i" "sh" "i") ("j" "ie" "j" "ie")))) (scheme (pyim-scheme-get 'quanpin))) (should (equal (pyim-preview-string scheme) "你好世界"))) - (let ((pyim-candidates '("世界" "时节" "使节" "视界" )) - (pyim-candidate-position 2) + (let ((pyim-process-candidates '("世界" "时节" "使节" "视界" )) + (pyim-process-candidate-position 2) (pyim-outcome-history nil) (pyim-imobjs '((("sh" "i" "sh" "i") ("j" "ie" "j" "ie")))) (scheme (pyim-scheme-get 'quanpin))) (should (equal (pyim-preview-string scheme) "时节"))) - (let ((pyim-candidates '("这是" "蛰是" "这时" "真实" "这使" "这事" "这" "者" "着" "折" "哲" "浙" "遮")) - (pyim-candidate-position 10) + (let ((pyim-process-candidates '("这是" "蛰是" "这时" "真实" "这使" "这事" "这" "者" "着" "折" "哲" "浙" "遮")) + (pyim-process-candidate-position 10) (pyim-outcome-history nil) (pyim-imobjs '((("zh" "e" "zh" "e") ("sh" "i" "sh" "i")))) (scheme (pyim-scheme-get 'quanpin))) (should (equal (pyim-preview-string scheme) "折shi"))) - (let ((pyim-candidates '("工" "藏匿" "工工" "花花草草" "㠭")) - (pyim-candidate-position 4) + (let ((pyim-process-candidates '("工" "藏匿" "工工" "花花草草" "㠭")) + (pyim-process-candidate-position 4) (pyim-outcome-history nil) (pyim-imobjs '(("aaaa"))) (scheme (pyim-scheme-get 'wubi)))