emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/pyim 22b7986: Add pyim-process-self-insert-command-p.


From: ELPA Syncer
Subject: [elpa] externals/pyim 22b7986: Add pyim-process-self-insert-command-p.
Date: Fri, 18 Jun 2021 03:57:12 -0400 (EDT)

branch: externals/pyim
commit 22b7986eaf31d04554b2bc61578ccf1200102560
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>

    Add pyim-process-self-insert-command-p.
    
        * pyim.el (pyim-input-method-1): Use pyim-process-self-insert-command-p.
        (pyim-self-insert-command-default): Removed.
        (pyim-self-insert-command): Update.
        (pyim-self-insert-command): push to pyim-process-self-insert-commands.
    
        * pyim-process.el (pyim-process-self-insert-commands): New variable.
        (pyim-process-run-1): Use pyim-process-self-insert-command-p.
        (pyim-process-self-insert-command-p): New function.
    
        * pyim-common.el (pyim-self-insert-command): Remove variable.
        (pyim-self-insert-command-p): Remove function.
---
 pyim-common.el  |  7 -------
 pyim-process.el | 11 +++++++++--
 pyim.el         | 10 ++--------
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/pyim-common.el b/pyim-common.el
index 36bf39c..8003582 100644
--- a/pyim-common.el
+++ b/pyim-common.el
@@ -40,9 +40,6 @@
 (defvar pyim-local-variable-list nil
   "A list of buffer local variable.")
 
-(defvar pyim-self-insert-command nil
-  "Self insert command used by pyim.")
-
 (defun pyim-register-local-variables (vars)
   "Recode variables VARS to `pyim-local-variable-list'."
   (dolist (var vars)
@@ -60,10 +57,6 @@
   (mapc #'kill-local-variable pyim-local-variable-list)
   (mapc #'make-local-variable pyim-local-variable-list))
 
-(defun pyim-self-insert-command-p (cmd)
-  "Test a command is a self insert command or not."
-  (eq cmd pyim-self-insert-command))
-
 (defun pyim-string-match-p (regexp string &optional start)
   "与 `string-match-p' 类似,如果 REGEXP 和 STRING 是非字符串时,
 不会报错。"
diff --git a/pyim-process.el b/pyim-process.el
index 2df402e..65f6c66 100644
--- a/pyim-process.el
+++ b/pyim-process.el
@@ -74,6 +74,9 @@
 (defvar pyim-process-run-async-timer nil
   "异步处理 entered 时,使用的 timer.")
 
+(defvar pyim-process-self-insert-commands nil
+  "保存所有的 self insert command.")
+
 (defvar pyim-process-run-exhibit-timer nil)
 
 (pyim-register-local-variables
@@ -226,7 +229,7 @@
        ((and
          ;; autoselector 功能会影响手动连续选择功能,所以这里做了一些限制,
          ;; 只有在输入的时候才能够触发 autoselector 机制。
-         (pyim-self-insert-command-p this-command)
+         (pyim-process-self-insert-command-p this-command)
          (cl-find-if (lambda (x)
                        (setq result x)
                        (equal (plist-get x :select) 'last))
@@ -248,7 +251,7 @@
        ;; entered 就是 "nihao". 如果 autoselector 函数返回一个 list:
        ;; (:select current), 那么就直接将 "nihao" 对应的第一个候选词
        ;; 上屏幕。
-       ((and (pyim-self-insert-command-p this-command)
+       ((and (pyim-process-self-insert-command-p this-command)
              (cl-find-if (lambda (x)
                            (setq result x)
                            (equal (plist-get x :select) 'current))
@@ -266,6 +269,10 @@
           (pyim-preview-refresh)
           (pyim-page-refresh))))))
 
+(defun pyim-process-self-insert-command-p (cmd)
+  "测试 CMD 是否是一个 pyim self insert command."
+  (member cmd pyim-process-self-insert-commands))
+
 (defun pyim-process-run-with-thread ()
   "Function used by `pyim-process-run-async-timer'"
   (let* ((scheme-name (pyim-scheme-name))
diff --git a/pyim.el b/pyim.el
index 995f4cd..5f5dee7 100644
--- a/pyim.el
+++ b/pyim.el
@@ -196,7 +196,7 @@ Tip: 用户也可以利用 `pyim-outcome-trigger-function-default' 函数
             ;;          key cmd last-command last-command-event this-command)
             (if (if key
                     (commandp cmd)
-                  (pyim-self-insert-command-p cmd))
+                  (pyim-process-self-insert-command-p cmd))
                 (progn
                   ;; (message "keyseq: %s" keyseq)
                   (setq last-command-event (aref keyseq (1- (length keyseq)))
@@ -299,12 +299,6 @@ REFRESH-COMMON-DCACHE 已经废弃,不要再使用了。"
 
 ;; ** 键盘输入处理功能
 (defun pyim-self-insert-command ()
-  "Call `pyim-self-insert-command'."
-  (interactive "*")
-  (when (functionp pyim-self-insert-command)
-    (call-interactively pyim-self-insert-command)))
-
-(defun pyim-self-insert-command-default ()
   "Pyim 默认的 self-insert-command."
   (interactive "*")
   (setq pyim-candidates-last pyim-candidates)
@@ -322,7 +316,7 @@ REFRESH-COMMON-DCACHE 已经废弃,不要再使用了。"
     (pyim-process-outcome-handle 'last-char)
     (pyim-process-terminate))))
 
-(setq pyim-self-insert-command #'pyim-self-insert-command-default)
+(cl-pushnew 'pyim-self-insert-command pyim-process-self-insert-commands)
 
 ;; ** 加词功能
 (defun pyim-create-word-at-point (&optional number silent)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]