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

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

[elpa] externals/pyim 289f87d 2/8: Move pyim-wash-function to pyim.el


From: ELPA Syncer
Subject: [elpa] externals/pyim 289f87d 2/8: Move pyim-wash-function to pyim.el
Date: Fri, 23 Apr 2021 00:57:12 -0400 (EDT)

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

    Move pyim-wash-function to pyim.el
---
 pyim-outcome.el | 39 ++++-----------------------------------
 pyim.el         | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/pyim-outcome.el b/pyim-outcome.el
index 1a761b1..b2731b3 100644
--- a/pyim-outcome.el
+++ b/pyim-outcome.el
@@ -83,13 +83,6 @@ pyim 使用函数 `pyim-outcome-handle-char' 来处理特殊功能触发字符
 具体请参考 `pyim-outcome-get-trigger-char' 。"
   :type '(choice (const nil) string))
 
-(defcustom pyim-wash-function 'pyim-wash-current-line-function
-  "清洗光标前面的文字内容.
-这个函数与『单字快捷键配合使用』,当光标前面的字符为汉字字符时,
-按 `pyim-outcome-trigger-char' 对应字符,可以调用这个函数来清洗
-光标前面的文字内容。"
-  :type 'function)
-
 (defvar pyim-outcome-history nil
   "记录 pyim outcome 的变化的历史
 
@@ -175,8 +168,10 @@ pyim 的 translate-trigger-char 要占用一个键位,为了防止用户
           prefer-trigger-chars)
       user-trigger-char)))
 
+;; Fix compile warn.
 (declare-function pyim-create-word-at-point "pyim")
 (declare-function pyim-delete-word-at-point "pyim")
+(defvar pyim-wash-function)
 
 (defun pyim-outcome-handle-char (char)
   "Pyim 字符转换函数,主要用于处理标点符号.
@@ -232,7 +227,8 @@ alist 列表。"
      ;; 光标前面的字符为中文字符时,按 v 清洗当前行的内容。
      ((and (not (numberp punc-posit-before-1))
            (pyim-string-match-p "\\cc" str-before-1)
-           (equal str trigger-str))
+           (equal str trigger-str)
+           (functionp (bound-and-true-p pyim-wash-function)))
       (funcall pyim-wash-function)
       "")
 
@@ -287,33 +283,6 @@ alist 列表。"
      ;; 当输入的字符不是标点符号时,原样插入。
      (t str))))
 
-(defun pyim-wash-current-line-function ()
-  "清理当前行的内容,比如:删除不必要的空格,等。"
-  (interactive)
-  (let* ((begin (line-beginning-position))
-         (end (point))
-         (string (buffer-substring-no-properties begin end))
-         new-string)
-    (when (> (length string) 0)
-      (delete-region begin end)
-      (setq new-string
-            (with-temp-buffer
-              (insert string)
-              (goto-char (point-min))
-              (while (re-search-forward "\\([,。;?!;、)】]\\)  
+\\([[:ascii:]]\\)" nil t)
-                (replace-match (concat (match-string 1) (match-string 2))  nil 
t))
-              (goto-char (point-min))
-              (while (re-search-forward "\\([[:ascii:]]\\)  +\\([(【]\\)" nil t)
-                (replace-match (concat (match-string 1) (match-string 2))  nil 
t))
-              (goto-char (point-min))
-              (while (re-search-forward "\\([[:ascii:]]\\)  +\\(\\cc\\)" nil t)
-                (replace-match (concat (match-string 1) " " (match-string 2))  
nil t))
-              (goto-char (point-min))
-              (while (re-search-forward "\\(\\cc\\)  +\\([[:ascii:]]\\)" nil t)
-                (replace-match (concat (match-string 1) " " (match-string 2))  
nil t))
-              (buffer-string)))
-      (insert new-string))))
-
 ;; * Footer
 (provide 'pyim-outcome)
 
diff --git a/pyim.el b/pyim.el
index 5aaf732..5ef4a60 100644
--- a/pyim.el
+++ b/pyim.el
@@ -83,6 +83,13 @@
 这个功能可以实现“简转繁”,“输入中文得到英文”之类的功能。"
   :type 'boolean)
 
+(defcustom pyim-wash-function 'pyim-wash-current-line-function
+  "清洗光标前面的文字内容.
+这个函数与『单字快捷键配合使用』,当光标前面的字符为汉字字符时,
+按 `pyim-outcome-trigger-char' 对应字符,可以调用这个函数来清洗
+光标前面的文字内容。"
+  :type 'function)
+
 ;;;###autoload
 (defvar pyim-titles '("PYIM " "PYIM-EN " "PYIM-AU ") "Pyim 在 mode-line 
中显示的名称.")
 
@@ -458,6 +465,33 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
             result))
     str))
 
+(defun pyim-wash-current-line-function ()
+  "清理当前行的内容,比如:删除不必要的空格,等。"
+  (interactive)
+  (let* ((begin (line-beginning-position))
+         (end (point))
+         (string (buffer-substring-no-properties begin end))
+         new-string)
+    (when (> (length string) 0)
+      (delete-region begin end)
+      (setq new-string
+            (with-temp-buffer
+              (insert string)
+              (goto-char (point-min))
+              (while (re-search-forward "\\([,。;?!;、)】]\\)  
+\\([[:ascii:]]\\)" nil t)
+                (replace-match (concat (match-string 1) (match-string 2))  nil 
t))
+              (goto-char (point-min))
+              (while (re-search-forward "\\([[:ascii:]]\\)  +\\([(【]\\)" nil t)
+                (replace-match (concat (match-string 1) (match-string 2))  nil 
t))
+              (goto-char (point-min))
+              (while (re-search-forward "\\([[:ascii:]]\\)  +\\(\\cc\\)" nil t)
+                (replace-match (concat (match-string 1) " " (match-string 2))  
nil t))
+              (goto-char (point-min))
+              (while (re-search-forward "\\(\\cc\\)  +\\([[:ascii:]]\\)" nil t)
+                (replace-match (concat (match-string 1) " " (match-string 2))  
nil t))
+              (buffer-string)))
+      (insert new-string))))
+
 (defun pyim-start-translation (key)
   "Start translation of the typed character KEY-OR-STRING by pyim.
 Return the input string.



reply via email to

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