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

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

[elpa] externals/pyim eef07ae 1/4: 删除 pyim-magic.el, 简化代码。


From: ELPA Syncer
Subject: [elpa] externals/pyim eef07ae 1/4: 删除 pyim-magic.el, 简化代码。
Date: Thu, 23 Dec 2021 03:57:26 -0500 (EST)

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

    删除 pyim-magic.el, 简化代码。
    
        * pyim-process.el (pyim-process-get-outcome): Use 
pyim-outcome-magic-convert.
    
        * pyim-preview.el (pyim-preview-refresh): Use 
pyim-outcome-magic-convert.
    
        * pyim-outcome.el (pyim-outcome-magic-converter)
        (pyim-outcome-magic-convert-cache, pyim-outcome-magic-convert):
    
        * pyim-magic.el: removed.
---
 Development.org |  2 +-
 README.org      |  6 +++---
 pyim-magic.el   | 58 ---------------------------------------------------------
 pyim-outcome.el | 21 +++++++++++++++++++++
 pyim-preview.el |  2 +-
 pyim-process.el |  3 +--
 6 files changed, 27 insertions(+), 65 deletions(-)

diff --git a/Development.org b/Development.org
index 2c6008e..97ac212 100644
--- a/Development.org
+++ b/Development.org
@@ -14,7 +14,7 @@
 
+----------------------+-----------------+------------------------------------------------+
                          |
 | PYIM 流程组件层:    | Process         | PYIM 视图组件层: Page, Preview, Indicator     
|     Assistant-scheme     |
 
+----------------------+-----------------+------------------------------------------------|
                          |
-| PYIM 实体组件层:    | Entered, Imobjs, Codes, Candidates, Outcome, Magic-convert, 
     |         Common           |
+| PYIM 实体组件层:    | Entered, Imobjs, Codes, Candidates, Outcome,                
     |         Common           |
 |                      | Punctuations, Cregexp, Cstring, Probe,                
           |                          |
 |                      | Autoselector, Pinyin                                  
           |                          |
 
+----------------------+-----------------------------------------+------------------------+
                          |
diff --git a/README.org b/README.org
index c75f5e9..3228f5c 100644
--- a/README.org
+++ b/README.org
@@ -220,15 +220,15 @@ pyim 的选词框默认使用 *双行显示* 的样式,在一些特殊的情
 用户可以将待选词 “特殊处理” 后再 “上屏”,比如 “简体转繁体” 或者 “输入中文,上屏
 英文” 之类的。
 
-用户需要设置 `pyim-magic-converter', 比如:下面这个例子实现,输入 “二呆”,“一个
-超级帅的小伙子” 上屏 :-)
+用户需要设置 `pyim-outcome-magic-converter', 比如:下面这个例子实现,输入 “二呆”,
+“一个超级帅的小伙子” 上屏 :-)
 
 #+begin_example
 (defun my-converter (string)
   (if (equal string "二呆")
       "“一个超级帅的小伙子”"
     string))
-(setq pyim-magic-converter #'my-converter)
+(setq pyim-outcome-magic-converter #'my-converter)
 #+end_example
 
 ** 切换全角标点与半角标点
diff --git a/pyim-magic.el b/pyim-magic.el
deleted file mode 100644
index b304e29..0000000
--- a/pyim-magic.el
+++ /dev/null
@@ -1,58 +0,0 @@
-;;; pyim-magic.el --- magic convert for pyim.        -*- lexical-binding: t; 
-*-
-
-;; * Header
-;; Copyright (C) 2021 Free Software Foundation, Inc.
-
-;; Author: Feng Shu <tumashu@163.com>
-;; Maintainer: Feng Shu <tumashu@163.com>
-;; URL: https://github.com/tumashu/pyim
-;; Keywords: convenience, Chinese, pinyin, input-method
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;;; Code:
-;; * 代码                                                           :code:
-(require 'cl-lib)
-
-(defgroup pyim-magic nil
-  "Magic converter for pyim."
-  :group 'pyim)
-
-(defcustom pyim-magic-converter nil
-  "将 “待选词条” 在 “上屏” 之前自动转换为其他字符串.
-这个功能可以实现“简转繁”,“输入中文得到英文”之类的功能。"
-  :type 'boolean)
-
-(defvar pyim-magic-convert-cache nil
-  "用来临时保存 `pyim-magic-convert' 的结果.
-从而加快同一个字符串第二次的转换速度。")
-
-(defun pyim-magic-convert (str)
-  "用于处理 `pyim-magic-converter' 的函数。"
-  (if (functionp pyim-magic-converter)
-      (or (cdr (assoc str pyim-magic-convert-cache))
-          (let ((result (funcall pyim-magic-converter str)))
-            (setq pyim-magic-convert-cache
-                  `((,str . ,result)))
-            result))
-    str))
-
-;; * Footer
-(provide 'pyim-magic)
-
-;;; pyim-magic.el ends here
diff --git a/pyim-outcome.el b/pyim-outcome.el
index 29c9af3..46b4b60 100644
--- a/pyim-outcome.el
+++ b/pyim-outcome.el
@@ -34,6 +34,13 @@
   "Outcome tools for pyim."
   :group 'pyim)
 
+(defcustom pyim-outcome-magic-converter nil
+  "将 “待选词条” 在 “上屏” 之前自动转换为其他字符串.
+这个功能可以实现“简转繁”,“输入中文得到英文”之类的功能。"
+  :type 'function)
+
+(defvaralias 'pyim-magic-converter 'pyim-outcome-magic-converter)
+
 (defcustom pyim-outcome-trigger "v"
   "用于触发特殊操作的字符,相当与单字快捷键.
 
@@ -114,6 +121,10 @@ pyim 使用函数 `pyim-process-outcome-handle-char' 来处理特殊功能触发
 (defvar pyim-outcome-subword-info nil
   "在以词定字功能中,用来保存字的位置。")
 
+(defvar pyim-outcome-magic-convert-cache nil
+  "用来临时保存 `pyim-outcome-magic-convert' 的结果.
+从而加快同一个字符串第二次的转换速度。")
+
 (pyim-register-local-variables '(pyim-outcome-history))
 
 ;; ** 选词框相关函数
@@ -131,6 +142,16 @@ pyim 使用函数 `pyim-process-outcome-handle-char' 来处理特殊功能触发
         (string-join output))
     word))
 
+(defun pyim-outcome-magic-convert (str)
+  "用于处理 `pyim-outcome-magic-converter' 的函数。"
+  (if (functionp pyim-outcome-magic-converter)
+      (or (cdr (assoc str pyim-outcome-magic-convert-cache))
+          (let ((result (funcall pyim-outcome-magic-converter str)))
+            (setq pyim-outcome-magic-convert-cache
+                  `((,str . ,result)))
+            result))
+    str))
+
 (defun pyim-outcome-get-trigger ()
   "检查 `pyim-outcome-trigger' 是否为一个合理的 trigger char 。
 
diff --git a/pyim-preview.el b/pyim-preview.el
index 4f7f461..1462647 100644
--- a/pyim-preview.el
+++ b/pyim-preview.el
@@ -85,7 +85,7 @@ pyim 会使用 Emacs overlay 机制在 *待输入buffer* 光标处高亮显示
         (when (string< "" rest)
           (setq preview (concat preview rest)))))
     (setq preview
-          (pyim-magic-convert
+          (pyim-outcome-magic-convert
            (pyim-outcome-get-subword preview)))
     ;; Delete old preview string.
     (pyim-preview-delete-string)
diff --git a/pyim-process.el b/pyim-process.el
index 95be87b..b2916a4 100644
--- a/pyim-process.el
+++ b/pyim-process.el
@@ -42,7 +42,6 @@
 (require 'pyim-punctuation)
 (require 'pyim-autoselector)
 (require 'pyim-cstring)
-(require 'pyim-magic)
 
 (defgroup pyim-process nil
   "Process for pyim."
@@ -362,7 +361,7 @@
       (setq str (pyim-outcome-get-subword str))
       (setq pyim-outcome-subword-info nil))
     (when magic-convert
-      (setq str (pyim-magic-convert str)))
+      (setq str (pyim-outcome-magic-convert str)))
     str))
 
 (defun pyim-process-outcome-handle (type)



reply via email to

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