branch: externals/pyim
commit 30baab215b7c3f02286429dc7d570d0f614d1c7c
Author: Feng Shu <tuma...@163.com>
Commit: Feng Shu <tuma...@163.com>

    pyim-terminate-translation -> pyim-refresh-terminate
    
        * pyim.el (pyim-start-translation, pyim-self-insert-command)
        (pyim-select-word-simple, pyim-select-word)
        (pyim-select-word:pinyin, pyim-select-word:xingma)
        (pyim-select-word-by-number, pyim-quit-clear)
        (pyim-quit-no-clear, pyim-toggle-assistant-scheme)
        (pyim-entered-delete-backward-char): Use pyim-refresh-terminate instead.
    
        * pyim-refresh.el (pyim-refresh, pyim-refresh-1): Use 
pyim-refresh-terminate instead.
        (pyim-refresh-terminate): Move from pyim-terminate-translation.
    
        * pyim-page.el (pyim-page-next-page, pyim-page-next-word): Use 
pyim-refresh-terminate instead.
    
        * pyim-liberime.el (pyim-select-word:rime)
        (pyim-create-rime-word, pyim-refresh-terminate:rime): Use 
pyim-refresh-terminate instead.
---
 pyim-liberime.el |  6 +++---
 pyim-page.el     |  6 +++---
 pyim-refresh.el  | 25 ++++++++++++++++++++-----
 pyim.el          | 41 ++++++++++++-----------------------------
 4 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/pyim-liberime.el b/pyim-liberime.el
index 9e89d20..f232f73 100644
--- a/pyim-liberime.el
+++ b/pyim-liberime.el
@@ -168,7 +168,7 @@
           (pyim-create-pyim-word (pyim-outcome-get))))
       (setq pyim-liberime-code-log nil)
       (setq pyim-liberime-word-log nil)
-      (pyim-terminate-translation)
+      (pyim-refresh-terminate)
       ;; pyim 使用这个 hook 来处理联想词。
       (run-hooks 'pyim-select-finish-hook))))
 
@@ -237,7 +237,7 @@ ONlY works with quanpin."
             (pyim-liberime-create-word
              (split-string code "-")
              (remove "" (split-string word "")))
-            (pyim-terminate-translation:rime)))))))
+            (pyim-refresh-terminate:rime)))))))
 
 (advice-add 'pyim-create-word :after #'pyim-create-rime-word)
 
@@ -290,7 +290,7 @@ Please see: https://github.com/rime/librime/issues/349";
    ;; 找不到通用的处理方式的话就不做截取处理。
    (t input)))
 
-(defun pyim-terminate-translation:rime ()
+(defun pyim-refresh-terminate:rime ()
   (liberime-clear-commit)
   (liberime-clear-composition))
 
diff --git a/pyim-page.el b/pyim-page.el
index 8d3793e..69e1b0b 100644
--- a/pyim-page.el
+++ b/pyim-page.el
@@ -219,7 +219,7 @@ page 的概念,比如,上面的 “nihao” 的 *待选词列表* 就可以
              (overlay-start pyim-preview-overlay)))
            (t (message (pyim-page-style:minibuffer page-info)))))))))
 
-(declare-function pyim-terminate-translation "pyim")
+(declare-function pyim-refresh-terminate "pyim-refresh")
 
 (defun pyim-page-next-page (arg)
   "Pyim page 翻页命令.
@@ -236,7 +236,7 @@ page 的概念,比如,上面的 “nihao” 的 *待选词列表* 就可以
   (if (= (length (pyim-entered-get 'point-before)) 0)
       (progn
         (pyim-outcome-handle 'last-char)
-        (pyim-terminate-translation))
+        (pyim-refresh-terminate))
     (let ((new (+ pyim-candidate-position (* pyim-page-length arg) 1))
           maxpos)
       (setq maxpos (+ 1 (length pyim-candidates)))
@@ -257,7 +257,7 @@ page 的概念,比如,上面的 “nihao” 的 *待选词列表* 就可以
   (if (= (length (pyim-entered-get 'point-before)) 0)
       (progn
         (pyim-outcome-handle 'last-char)
-        (pyim-terminate-translation))
+        (pyim-refresh-terminate))
     (let ((new (+ pyim-candidate-position arg))
           len)
       (setq len (length pyim-candidates))
diff --git a/pyim-refresh.el b/pyim-refresh.el
index 571f3a4..6b63b4c 100644
--- a/pyim-refresh.el
+++ b/pyim-refresh.el
@@ -33,12 +33,10 @@
 (defvar pyim-refresh-timer nil
   "异步处理 intered 时时,使用的 timer.")
 
-(declare-function pyim-terminate-translation "pyim")
-
 (defun pyim-refresh (&optional no-delay)
   "延迟 `pyim-entered-exhibit-delay-ms' 显示备选词等待用户选择。"
   (if (= (length (pyim-entered-get 'point-before)) 0)
-      (pyim-terminate-translation)
+      (pyim-refresh-terminate)
     (when pyim-entered--exhibit-timer
       (cancel-timer pyim-entered--exhibit-timer))
     (cond
@@ -109,7 +107,7 @@
         (pyim-add-unread-command-events
          (listify-key-sequence (pyim-entered-get 'point-after)))
         (pyim-add-unread-command-events last-command-event)
-        (pyim-terminate-translation))
+        (pyim-refresh-terminate))
        ;; 假设用户已经输入 "niha", 然后按了 "o" 键,那么,当前
        ;; entered 就是 "nihao". 如果 autoselector 函数返回一个 list:
        ;; (:select current), 那么就直接将 "nihao" 对应的第一个候选词
@@ -127,7 +125,7 @@
           (pyim-outcome-handle 'candidate))
         (pyim-add-unread-command-events
          (listify-key-sequence (pyim-entered-get 'point-after)))
-        (pyim-terminate-translation))
+        (pyim-refresh-terminate))
        (t (setq pyim-candidate-position 1)
           (pyim-preview-refresh)
           (pyim-page-refresh))))))
@@ -150,6 +148,23 @@
     (cancel-timer pyim-refresh-timer)
     (setq pyim-refresh-timer nil)))
 
+(defalias 'pyim-terminate-translation #'pyim-refresh-terminate)
+(defun pyim-refresh-terminate ()
+  "Terminate the translation of the current key."
+  (setq pyim-translating nil)
+  (pyim-preview-delete-string)
+  (setq pyim-candidates nil)
+  (setq pyim-candidates-last nil)
+  (setq pyim-force-input-chinese nil)
+  (pyim-page-hide)
+  (pyim-entered-erase-buffer)
+  (setq pyim-cstring-to-code-criteria nil)
+  (pyim-refresh-timer-reset)
+  (let* ((class (pyim-scheme-get-option (pyim-scheme-name) :class))
+         (func (intern (format "pyim-refresh-terminate:%S" class))))
+    (when (and class (functionp func))
+      (funcall func))))
+
 ;; * Footer
 (provide 'pyim-refresh)
 
diff --git a/pyim.el b/pyim.el
index 7c3ef99..2f276a5 100644
--- a/pyim.el
+++ b/pyim.el
@@ -268,7 +268,7 @@ Return the input string.
               ;; Let's return the event(s) to the caller.
               (pyim-add-unread-command-events (this-single-command-raw-keys) t)
               ;; (message "unread-command-events: %s" unread-command-events)
-              (pyim-terminate-translation))))
+              (pyim-refresh-terminate))))
         ;; (message "return: %s" (pyim-outcome-get))
         (pyim-magic-convert (pyim-outcome-get)))
     ;; Since KEY doesn't start any translation, just return it.
@@ -383,10 +383,10 @@ REFRESH-COMMON-DCACHE 已经废弃,不要再使用了。"
     (pyim-refresh))
    (pyim-candidates
     (pyim-outcome-handle 'candidate-and-last-char)
-    (pyim-terminate-translation))
+    (pyim-refresh-terminate))
    (t
     (pyim-outcome-handle 'last-char)
-    (pyim-terminate-translation))))
+    (pyim-refresh-terminate))))
 
 (defun pyim-auto-switch-english-input-p ()
   "判断是否 *根据环境自动切换* 为英文输入模式,这个函数处理变量:
@@ -419,23 +419,6 @@ REFRESH-COMMON-DCACHE 已经废弃,不要再使用了。"
                    (mapcar #'identity rest-chars)))
          (setq current-input-method-title (nth 0 pyim-titles)))))
 
-;; ** 键盘输入停止功能
-(defun pyim-terminate-translation ()
-  "Terminate the translation of the current key."
-  (setq pyim-translating nil)
-  (pyim-preview-delete-string)
-  (setq pyim-candidates nil)
-  (setq pyim-candidates-last nil)
-  (setq pyim-force-input-chinese nil)
-  (pyim-page-hide)
-  (pyim-entered-erase-buffer)
-  (setq pyim-cstring-to-code-criteria nil)
-  (pyim-refresh-timer-reset)
-  (let* ((class (pyim-scheme-get-option (pyim-scheme-name) :class))
-         (func (intern (format "pyim-terminate-translation:%S" class))))
-    (when (and class (functionp func))
-      (funcall func))))
-
 ;; ** 加词功能
 (defun pyim-create-word (word &optional prepend wordcount-handler)
   (pyim-create-pyim-word word prepend wordcount-handler))
@@ -578,7 +561,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   (if (null pyim-candidates)
       (pyim-outcome-handle 'last-char)
     (pyim-outcome-handle 'candidate))
-  (pyim-terminate-translation))
+  (pyim-refresh-terminate))
 
 (define-obsolete-function-alias 'pyim-page-select-word 'pyim-select-word "4.0")
 (defun pyim-select-word ()
@@ -595,7 +578,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   (if (null pyim-candidates)  ; 如果没有选项,输入空格
       (progn
         (pyim-outcome-handle 'last-char)
-        (pyim-terminate-translation))
+        (pyim-refresh-terminate))
     (let* ((class (pyim-scheme-get-option (pyim-scheme-name) :class))
            (func (intern (format "pyim-select-word:%S" class))))
       (if (and class (functionp func))
@@ -668,7 +651,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
           (pyim-create-pyim-word (pyim-outcome-get) t)
         (pyim-create-pyim-word (pyim-outcome-get)))
 
-      (pyim-terminate-translation)
+      (pyim-refresh-terminate)
       ;; pyim 使用这个 hook 来处理联想词。
       (run-hooks 'pyim-select-finish-hook))))
 
@@ -690,7 +673,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
       (if (member (pyim-outcome-get) pyim-candidates)
           (pyim-create-pyim-word (pyim-outcome-get) t)
         (pyim-create-pyim-word (pyim-outcome-get))))
-    (pyim-terminate-translation)
+    (pyim-refresh-terminate)
     ;; pyim 使用这个 hook 来处理联想词。
     (run-hooks 'pyim-select-finish-hook)))
 
@@ -702,7 +685,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
       (if (null pyim-candidates)
           (progn
             (pyim-outcome-handle 'last-char)
-            (pyim-terminate-translation))
+            (pyim-refresh-terminate))
         (let ((index (if (numberp n)
                          (- n 1)
                        (- last-command-event ?1)))
@@ -722,14 +705,14 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   "取消当前输入的命令."
   (interactive)
   (pyim-outcome-handle "")
-  (pyim-terminate-translation))
+  (pyim-refresh-terminate))
 
 ;; ** 字母上屏功能
 (defun pyim-quit-no-clear ()
   "字母上屏命令."
   (interactive)
   (pyim-outcome-handle 'pyim-entered)
-  (pyim-terminate-translation))
+  (pyim-refresh-terminate))
 
 ;; ** 取消激活功能
 (defun pyim-inactivate ()
@@ -755,7 +738,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   (if (= (length (pyim-entered-get 'point-before)) 0)
       (progn
         (pyim-outcome-handle 'last-char)
-        (pyim-terminate-translation))
+        (pyim-refresh-terminate))
     (setq pyim-assistant-scheme-enable
           (not pyim-assistant-scheme-enable))
     (pyim-refresh)))
@@ -815,7 +798,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   (if (> (length (pyim-entered-get 'point-before)) 0)
       (pyim-refresh t)
     (pyim-outcome-handle "")
-    (pyim-terminate-translation)))
+    (pyim-refresh-terminate)))
 
 (defun pyim-entered-delete-forward-char ()
   "在pyim-entered-buffer中向前删除1个字符"

Reply via email to