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

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

[elpa] externals/pyim a258f60048 4/5: Add pyim-char-before-to-number


From: ELPA Syncer
Subject: [elpa] externals/pyim a258f60048 4/5: Add pyim-char-before-to-number
Date: Tue, 28 Jun 2022 18:57:50 -0400 (EDT)

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

    Add pyim-char-before-to-number
---
 pyim-common.el  |  4 ++++
 pyim-process.el | 16 +++++++---------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/pyim-common.el b/pyim-common.el
index 82bf46c9bc..307c40d185 100644
--- a/pyim-common.el
+++ b/pyim-common.el
@@ -146,6 +146,10 @@ When CARE-FIRST-ONE is no-nil, ((a b c) (d e)) => (a d)."
     (when (char-after point-after)
       (char-to-string (char-after point-after)))))
 
+(defun pyim-char-before-to-number (num)
+  (string-to-number
+   (pyim-char-before-to-string num)))
+
 (if (fboundp 'string-distance)
     (defalias 'pyim-string-distance 'string-distance)
   (defun pyim-string-distance (s1 s2)
diff --git a/pyim-process.el b/pyim-process.el
index b38b3c974c..0ba0e2b377 100644
--- a/pyim-process.el
+++ b/pyim-process.el
@@ -866,17 +866,15 @@ BUG:拼音无法有效地处理多音字。"
      ((pyim-process--invalid-char-p char) "")
 
      ((pyim-process--trigger-delete-word-p char)
-      (let ((str-before-2 (pyim-char-before-to-string 1)))
+      (let ((number-before-2 (pyim-char-before-to-number 1)))
         (delete-char -2)
-        (pyim-process-delete-word-at-point
-         (string-to-number str-before-2)))
+        (pyim-process-delete-word-at-point number-before-2))
       "")
 
      ((pyim-process--trigger-create-word-p char)
-      (let ((str-before-1 (pyim-char-before-to-string 0)))
+      (let ((number-before-1 (pyim-char-before-to-number 0)))
         (delete-char -1)
-        (pyim-process-create-word-at-point
-         (string-to-number str-before-1)))
+        (pyim-process-create-word-at-point number-before-1))
       "")
 
      ((pyim-process--trigger-call-function-p char)
@@ -916,7 +914,7 @@ BUG:拼音无法有效地处理多音字。"
 (defun pyim-process-delete-word-at-point (&optional number silent)
   "将光标前字符数为 NUMBER 的中文字符串从个人词库中删除
 当 SILENT 设置为 t 是,不显示提醒信息。"
-  (let ((string (pyim-cstring-at-point (or number 2))))
+  (let* ((string (pyim-cstring-at-point (or number 2))))
     (when string
       (pyim-process-delete-word string)
       (unless silent
@@ -933,8 +931,8 @@ BUG:拼音无法有效地处理多音字。"
 (defun pyim-process-create-word-at-point (&optional number silent)
   "将光标前字符数为 NUMBER 的中文字符串添加到个人词库中,当
 SILENT 设置为 t 是,不显示提醒信息。"
-  (let ((string (pyim-cstring-at-point (or number 2)))
-        output)
+  (let* ((string (pyim-cstring-at-point (or number 2)))
+         output)
     (when string
       (setq output (pyim-process-create-word string))
       (unless silent



reply via email to

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