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

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

[elpa] externals/pyim b9732d2821: Remove pyim-exhibit-delay-ms


From: ELPA Syncer
Subject: [elpa] externals/pyim b9732d2821: Remove pyim-exhibit-delay-ms
Date: Tue, 7 Jun 2022 05:57:56 -0400 (EDT)

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

    Remove pyim-exhibit-delay-ms
    
    现在 pyim 的速度已经很快了,我感觉这个功能已经没有必要了,删除它可以显著降低代码
    复杂度,因为 pyim 添加了延迟获取词条的功能,两个功能都使用 timer, 导致代码很复杂,
    难以了解。
---
 pyim-process.el | 50 ++++++++++++++------------------------------------
 pyim.el         | 16 ++++++++--------
 2 files changed, 22 insertions(+), 44 deletions(-)

diff --git a/pyim-process.el b/pyim-process.el
index cbf0cf5559..2566038f3a 100644
--- a/pyim-process.el
+++ b/pyim-process.el
@@ -81,12 +81,6 @@ entered (nihaom) 的第一个候选词。
   :type '(choice (const nil)
                  (repeat function)))
 
-(defcustom pyim-exhibit-delay-ms 0
-  "输入或者删除拼音字符后等待多少毫秒后才显示可选词
-当用户快速输入连续的拼音时可提升用户体验.
-如果为 0 或者 nil, 则不等待立刻显示可选词."
-  :type 'integer)
-
 (define-obsolete-variable-alias
   'pyim-process-async-delay 'pyim-process-run-delay "5.0")
 
@@ -124,8 +118,6 @@ entered (nihaom) 的第一个候选词。
 (defvar pyim-process-self-insert-commands nil
   "保存所有的 self insert command.")
 
-(defvar pyim-process-run-exhibit-timer nil)
-
 (defvar pyim-process-ui-init-hook nil
   "Hook used to run ui init functions.")
 
@@ -261,36 +253,22 @@ entered (nihaom) 的第一个候选词。
       (and (not pyim-process-input-ascii)
            (not (pyim-process-auto-switch-english-input-p)))))
 
-(defun pyim-process-run (&optional no-delay)
-  "延迟 `pyim-exhibit-delay-ms' 显示备选词等待用户选择。"
+(defun pyim-process-run ()
+  "查询 entered 字符串, 显示备选词等待用户选择。"
   (if (= (length (pyim-entered-get 'point-before)) 0)
       (pyim-process-terminate)
-    (when pyim-process-run-exhibit-timer
-      (cancel-timer pyim-process-run-exhibit-timer))
-    (cond
-     ((or no-delay
-          (not pyim-exhibit-delay-ms)
-          (eq pyim-exhibit-delay-ms 0))
-      (pyim-process-run-1))
-     (t (setq pyim-process-run-exhibit-timer
-              (run-with-timer (/ pyim-exhibit-delay-ms 1000.0)
-                              nil
-                              #'pyim-process-run-1))))))
-
-(defun pyim-process-run-1 ()
-  "查询 `pyim-entered-buffer' 光标前的拼音字符串(如果光标在行首则为光标后的), 显示备选词等待用户选择。"
-  (let* ((scheme (pyim-scheme-current))
-         entered-to-translate)
-    (setq entered-to-translate
-          (pyim-entered-get 'point-before))
-    (setq pyim-imobjs (pyim-imobjs-create entered-to-translate scheme))
-    (setq pyim-candidates
-          (or (delete-dups (pyim-candidates-create pyim-imobjs scheme))
-              (list entered-to-translate)))
-    (unless (pyim-process-auto-select)
-      (setq pyim-candidate-position 1)
-      (pyim-process-ui-refresh)
-      (pyim-process-run-delay))))
+    (let* ((scheme (pyim-scheme-current))
+           entered-to-translate)
+      (setq entered-to-translate
+            (pyim-entered-get 'point-before))
+      (setq pyim-imobjs (pyim-imobjs-create entered-to-translate scheme))
+      (setq pyim-candidates
+            (or (delete-dups (pyim-candidates-create pyim-imobjs scheme))
+                (list entered-to-translate)))
+      (unless (pyim-process-auto-select)
+        (setq pyim-candidate-position 1)
+        (pyim-process-ui-refresh)
+        (pyim-process-run-delay)))))
 
 (defun pyim-process-auto-select ()
   "自动上屏操作。"
diff --git a/pyim.el b/pyim.el
index 332a1fe050..de2ccc859d 100644
--- a/pyim.el
+++ b/pyim.el
@@ -620,7 +620,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   "以词定字功能。"
   (interactive)
   (pyim-process-toggle-set-subword-info (or n 1))
-  (pyim-process-run t))
+  (pyim-process-run))
 
 ;; ** 翻页和翻词功能
 (defalias 'pyim-previous-page #'pyim-page-previous-page)
@@ -671,7 +671,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   (pyim-process-with-entered-buffer
     (ignore-errors
       (forward-char)))
-  (pyim-process-run t))
+  (pyim-process-run))
 
 (defun pyim-backward-point ()
   "光标后移"
@@ -679,7 +679,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   (pyim-process-with-entered-buffer
     (ignore-errors
       (backward-char)))
-  (pyim-process-run t))
+  (pyim-process-run))
 
 (defun pyim-backward-imelem (&optional search-forward)
   "光标向后移动一个 imelem 对应的字符串
@@ -689,7 +689,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   (let ((position (pyim-process-next-imelem-position 1 search-forward)))
     (pyim-process-with-entered-buffer
       (goto-char position))
-    (pyim-process-run t)))
+    (pyim-process-run)))
 
 (defun pyim-forward-imelem ()
   "光标向前移动一个 imelem 对应的字符串"
@@ -701,14 +701,14 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   (interactive)
   (pyim-process-with-entered-buffer
     (end-of-line))
-  (pyim-process-run t))
+  (pyim-process-run))
 
 (defun pyim-beginning-of-line ()
   "光标移至行首"
   (interactive)
   (pyim-process-with-entered-buffer
     (beginning-of-line))
-  (pyim-process-run t))
+  (pyim-process-run))
 
 (defun pyim-delete-backward-char (&optional n)
   "向后删除1个字符"
@@ -717,7 +717,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
     (ignore-errors
       (delete-char (- 0 (or n 1)))))
   (if (> (length (pyim-process-get-entered 'point-before)) 0)
-      (pyim-process-run t)
+      (pyim-process-run)
     (pyim-process-outcome-handle "")
     (pyim-process-terminate)))
 
@@ -732,7 +732,7 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
   (let ((position (pyim-process-next-imelem-position 1 search-forward)))
     (pyim-process-with-entered-buffer
       (delete-region (point) position))
-    (pyim-process-run t)))
+    (pyim-process-run)))
 
 (defun pyim-delete-forward-imelem ()
   "向前删除一个 imelem 对应的字符串"



reply via email to

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