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

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

[elpa] externals/pyim 440938c 8/8: split pyim-imobjs-codes to pyim-imobj


From: ELPA Syncer
Subject: [elpa] externals/pyim 440938c 8/8: split pyim-imobjs-codes to pyim-imobjs.el and pyim-codes.el
Date: Fri, 23 Apr 2021 00:57:13 -0400 (EDT)

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

    split pyim-imobjs-codes to pyim-imobjs.el and pyim-codes.el
---
 pyim-codes.el                          | 95 ++++++++++++++++++++++++++++++++++
 pyim-imobjs-codes.el => pyim-imobjs.el | 66 ++---------------------
 pyim.el                                |  3 +-
 3 files changed, 101 insertions(+), 63 deletions(-)

diff --git a/pyim-codes.el b/pyim-codes.el
new file mode 100644
index 0000000..d557c2f
--- /dev/null
+++ b/pyim-codes.el
@@ -0,0 +1,95 @@
+;;; pyim-codes.el --- codes lib 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)
+(require 'pyim-scheme)
+(require 'pyim-imobjs)
+
+(defun pyim-codes-create (imobj scheme-name &optional first-n)
+  "按照 SCHEME-NAME 对应的输入法方案,从一个 IMOBJ 创建一个列表 codes, 这个列表
+包含一个或者多个 code 字符串,这些 code 字符串用于从词库中搜索词条."
+  (let ((class (pyim-scheme-get-option scheme-name :class)))
+    (when class
+      (funcall (intern (format "pyim-codes-create:%S" class))
+               imobj scheme-name first-n))))
+
+(defun pyim-codes-create:quanpin (imobj _scheme-name &optional first-n)
+  "从IMOBJ 创建一个 code 列表:codes.
+
+列表 codes 中包含一个或者多个 code 字符串,这些 code 字符串用于从
+词库中搜索相关词条。
+
+    (pyim-codes-create '((\"w\" \"o\" \"w\" \"o\") (\"\" \"ai\" \"\" \"ai\") 
(\"m\" \"ei\" \"m\" \"ei\") (\"n\"  \"v\" \"n\"  \"v\")) 'quanpin)
+
+结果为:
+
+   (\"wo\" \"ai\" \"mei\" \"nv\")"
+  (mapcar
+   #'(lambda (w)
+       (let ((py (replace-regexp-in-string ;去掉分隔符,在词库中搜索候选词不需要分隔符
+                  "'" "" (concat (nth 0 w) (nth 1 w)))))
+         (if (numberp first-n)
+             (substring py 0 (min first-n (length py)))
+           py)))
+   imobj))
+
+(defun pyim-codes-create:shuangpin (imobj _scheme-name &optional first-n)
+  (pyim-codes-create:quanpin imobj 'quanpin first-n))
+
+(defun pyim-codes-create:xingma (imobj scheme-name &optional first-n)
+  (when scheme-name
+    (let ((code-prefix (pyim-scheme-get-option scheme-name :code-prefix)))
+      (mapcar
+       #'(lambda (x)
+           (concat (or code-prefix "")
+                   (if (numberp first-n)
+                       (substring x 0 (min first-n (length x)))
+                     x)))
+       imobj))))
+
+(defun pyim-code-search (word scheme-name)
+  "从 SCHEME-NAME 对应的输入法词库中,搜索 WORD 对应的 code.
+
+返回最长的 code."
+  (when (and (stringp word)
+             (> (length word) 0))
+    (let* ((prefix (pyim-scheme-get-option scheme-name :code-prefix))
+           (code
+            (cl-find-if
+             #'(lambda (x)
+                 (equal (substring (or x " ") 0 1) prefix))
+             (sort
+              (cl-copy-list (pyim-dcache-call-api 'search-word-code word))
+              #'(lambda (a b) (> (length a) (length b)))))))
+      (substring (or code " ") 1))))
+
+;; * Footer
+(provide 'pyim-codes)
+
+;;; pyim-imobjs.el ends here
diff --git a/pyim-imobjs-codes.el b/pyim-imobjs.el
similarity index 76%
rename from pyim-imobjs-codes.el
rename to pyim-imobjs.el
index 806a37e..297bfe9 100644
--- a/pyim-imobjs-codes.el
+++ b/pyim-imobjs.el
@@ -1,4 +1,4 @@
-;;; pyim-imobjs-codes.el --- imobjs and codes lib for pyim.        -*- 
lexical-binding: t; -*-
+;;; pyim-imobjs.el --- imobjs for pyim.        -*- lexical-binding: t; -*-
 
 ;; * Header
 ;; Copyright (C) 2021 Free Software Foundation, Inc.
@@ -29,8 +29,8 @@
 ;; * 代码                                                           :code:
 (require 'cl-lib)
 
-(defgroup pyim-imobjs-codes nil
-  "Imobjs and codes tools for pyim."
+(defgroup pyim-imobjs nil
+  "Imobjs lib for pyim."
   :group 'pyim)
 
 (defvar pyim-imobjs nil
@@ -205,65 +205,7 @@ imobj 组合构成在一起,构成了 imobjs 这个概念。比如:
           (push `(,a ,b ,@(nthcdr 2 imelem)) result)))
       (reverse result))))
 
-(defun pyim-codes-create (imobj scheme-name &optional first-n)
-  "按照 SCHEME-NAME 对应的输入法方案,从一个 IMOBJ 创建一个列表 codes, 这个列表
-包含一个或者多个 code 字符串,这些 code 字符串用于从词库中搜索词条."
-  (let ((class (pyim-scheme-get-option scheme-name :class)))
-    (when class
-      (funcall (intern (format "pyim-codes-create:%S" class))
-               imobj scheme-name first-n))))
-
-(defun pyim-codes-create:quanpin (imobj _scheme-name &optional first-n)
-  "从IMOBJ 创建一个 code 列表:codes.
-
-列表 codes 中包含一个或者多个 code 字符串,这些 code 字符串用于从
-词库中搜索相关词条。
-
-    (pyim-codes-create '((\"w\" \"o\" \"w\" \"o\") (\"\" \"ai\" \"\" \"ai\") 
(\"m\" \"ei\" \"m\" \"ei\") (\"n\"  \"v\" \"n\"  \"v\")) 'quanpin)
-
-结果为:
-
-   (\"wo\" \"ai\" \"mei\" \"nv\")"
-  (mapcar
-   #'(lambda (w)
-       (let ((py (replace-regexp-in-string ;去掉分隔符,在词库中搜索候选词不需要分隔符
-                  "'" "" (concat (nth 0 w) (nth 1 w)))))
-         (if (numberp first-n)
-             (substring py 0 (min first-n (length py)))
-           py)))
-   imobj))
-
-(defun pyim-codes-create:shuangpin (imobj _scheme-name &optional first-n)
-  (pyim-codes-create:quanpin imobj 'quanpin first-n))
-
-(defun pyim-codes-create:xingma (imobj scheme-name &optional first-n)
-  (when scheme-name
-    (let ((code-prefix (pyim-scheme-get-option scheme-name :code-prefix)))
-      (mapcar
-       #'(lambda (x)
-           (concat (or code-prefix "")
-                   (if (numberp first-n)
-                       (substring x 0 (min first-n (length x)))
-                     x)))
-       imobj))))
-
-(defun pyim-code-search (word scheme-name)
-  "从 SCHEME-NAME 对应的输入法词库中,搜索 WORD 对应的 code.
-
-返回最长的 code."
-  (when (and (stringp word)
-             (> (length word) 0))
-    (let* ((prefix (pyim-scheme-get-option scheme-name :code-prefix))
-           (code
-            (cl-find-if
-             #'(lambda (x)
-                 (equal (substring (or x " ") 0 1) prefix))
-             (sort
-              (cl-copy-list (pyim-dcache-call-api 'search-word-code word))
-              #'(lambda (a b) (> (length a) (length b)))))))
-      (substring (or code " ") 1))))
-
 ;; * Footer
-(provide 'pyim-imobjs-codes)
+(provide 'pyim-imobjs)
 
 ;;; pyim-imobjs.el ends here
diff --git a/pyim.el b/pyim.el
index 4dc4cd2..15684d8 100644
--- a/pyim.el
+++ b/pyim.el
@@ -42,7 +42,8 @@
 (require 'pyim-dict)
 (require 'pyim-dcache)
 (require 'pyim-scheme)
-(require 'pyim-imobjs-codes)
+(require 'pyim-imobjs)
+(require 'pyim-codes)
 (require 'pyim-page)
 (require 'pyim-entered)
 (require 'pyim-candidates)



reply via email to

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