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

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

[elpa] externals/pyim f207774: Add pyim-cstring-search-xingma and use it


From: ELPA Syncer
Subject: [elpa] externals/pyim f207774: Add pyim-cstring-search-xingma and use it.
Date: Wed, 5 May 2021 20:57:15 -0400 (EDT)

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

    Add pyim-cstring-search-xingma and use it.
    
        * pyim-page.el (pyim-page-preview-create:quanpin): Use 
pyim-cstring-to-xingma.
    
        * pyim-cstring.el (pyim-cstring-search-xingma)
        (pyim-cstring-to-xingma:wubi): Add pyim-cstring-search-xingma and use 
it.
    
        * pyim-codes.el (pyim-code-search): removed.
---
 pyim-codes.el   | 16 ----------------
 pyim-cstring.el | 22 +++++++++++++++++++---
 pyim-page.el    |  2 +-
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/pyim-codes.el b/pyim-codes.el
index 2d02584..f927bfa 100644
--- a/pyim-codes.el
+++ b/pyim-codes.el
@@ -74,22 +74,6 @@
                    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 (nth 0 (pyim-dcache-code-split x))
-                           prefix))
-                  (sort
-                   (cl-copy-list (pyim-dcache-call-api 'search-word-code word))
-                   (lambda (a b) (> (length a) (length b)))))))
-      (nth 1 (pyim-dcache-code-split code)))))
-
 ;; * Footer
 (provide 'pyim-codes)
 
diff --git a/pyim-cstring.el b/pyim-cstring.el
index 962930d..f80db9a 100644
--- a/pyim-cstring.el
+++ b/pyim-cstring.el
@@ -296,17 +296,33 @@ BUG: 当 STRING 中包含其它标点符号,并且设置 SEPERATER 时,结
   "返回汉字 STRING 对应形码方案 SCHEME-NAME 的 code (不包括
 code-prefix)。当RETURN-LIST 设置为 t 时,返回一个 code list。"
   (let* ((fun (intern (concat "pyim-cstring-to-xingma:" (symbol-name 
scheme-name))))
-         (code (and fun (funcall fun string))))
+         (code (and fun (funcall fun string scheme-name))))
     (when code
       (if return-list
           (list code)
         code))))
 
-(defun pyim-cstring-to-xingma:wubi (string)
+(defun pyim-cstring-search-xingma (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 (nth 0 (pyim-dcache-code-split x))
+                           prefix))
+                  (sort
+                   (cl-copy-list (pyim-dcache-call-api 'search-word-code word))
+                   (lambda (a b) (> (length a) (length b)))))))
+      (nth 1 (pyim-dcache-code-split code)))))
+
+(defun pyim-cstring-to-xingma:wubi (string &optional scheme-name)
   "返回汉字 STRING 的五笔编码(不包括 code-prefix)。当 RETURN-LIST
 设置为 t 时,返回一个编码列表。"
   (when (string-match-p "^\\cc+\\'" string)
-    (let ((code (pyim-code-search string 'wubi))
+    (let ((code (pyim-cstring-search-xingma string (or scheme-name 'wubi)))
           (len (length string)))
       (unless code
         (when (= len 1)
diff --git a/pyim-page.el b/pyim-page.el
index 53611d1..0fc3648 100644
--- a/pyim-page.el
+++ b/pyim-page.el
@@ -302,7 +302,7 @@ page 的概念,比如,上面的 “nihao” 的 *待选词列表* 就可以
      ;; 用于标记辅助输入法
      (when (and (eq pyim-assistant-scheme 'quanpin)
                 (eq pyim-assistant-scheme-enable t))
-       (let ((code (pyim-code-search
+       (let ((code (pyim-cstring-to-xingma
                     (pyim-candidate-parse
                      (nth (1- pyim-candidate-position)
                           pyim-candidates))



reply via email to

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