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

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

[elpa] externals/pyim eafaef3 22/36: update pyim-cstring.el


From: ELPA Syncer
Subject: [elpa] externals/pyim eafaef3 22/36: update pyim-cstring.el
Date: Thu, 22 Apr 2021 22:57:19 -0400 (EDT)

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

    update pyim-cstring.el
---
 pyim-cstring.el | 37 +++++++++++++++++++++++++++++++++++++
 pyim.el         | 36 ------------------------------------
 2 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/pyim-cstring.el b/pyim-cstring.el
index da89b06..e92e1fb 100644
--- a/pyim-cstring.el
+++ b/pyim-cstring.el
@@ -301,6 +301,43 @@ BUG: 当 STRING 中包含其它标点符号,并且设置 SEPERATER 时,结
   "简化版的 `pyim-cstring-to-pinyin', 不处理多音字。"
   (pyim-cstring-to-pinyin string shou-zi-mu separator return-list t))
 
+(defalias 'pyim-hanzi2xingma 'pyim-cstring-to-xingma)
+(defun pyim-cstring-to-xingma (string scheme-name &optional return-list)
+  "返回汉字 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))))
+    (when code
+      (if return-list
+          (list code)
+        code))))
+
+(defun pyim-cstring-to-xingma:wubi (string)
+  "返回汉字 STRING 的五笔编码(不包括 code-prefix)。当RETURN-LIST
+设置为 t 时,返回一个编码列表。"
+  (when (string-match-p "^\\cc+\\'" string)
+    (let ((code (pyim-code-search string 'wubi))
+          (len (length string)))
+      (when (string-empty-p code)
+        (when (= len 1)
+          (error "No code found for %s" string))
+        (setq string (split-string string "" t)
+              code
+              (cl-case len
+                ;; 双字词,分别取两个字的前两个编码
+                (2 (concat (substring (pyim-cstring-to-xingma:wubi (nth 0 
string)) 0 2)
+                           (substring (pyim-cstring-to-xingma:wubi (nth 1 
string)) 0 2)))
+                ;; 三字词,取前二字的首编码,及第三个字的前两个编码
+                (3 (concat (substring (pyim-cstring-to-xingma:wubi (nth 0 
string)) 0 1)
+                           (substring (pyim-cstring-to-xingma:wubi (nth 1 
string)) 0 1)
+                           (substring (pyim-cstring-to-xingma:wubi (nth 2 
string)) 0 2)))
+                ;; 四字词及以上,分别前三个字及最后一个字的首编码
+                (t (concat (substring (pyim-cstring-to-xingma:wubi (nth 0 
string)) 0 1)
+                           (substring (pyim-cstring-to-xingma:wubi (nth 1 
string)) 0 1)
+                           (substring (pyim-cstring-to-xingma:wubi (nth 2 
string)) 0 1)
+                           (substring (pyim-cstring-to-xingma:wubi (nth (1- 
len) string)) 0 1))))))
+      code)))
+
 (defalias 'pyim-cwords-at-point 'pyim-cstring-words-at-point)
 (defun pyim-cstring-words-at-point (&optional end-of-point)
   "获取光标当前的词条列表,当 END-OF-POINT 设置为 t 时,获取光标后的词条列表。
diff --git a/pyim.el b/pyim.el
index 8673f40..1541411 100644
--- a/pyim.el
+++ b/pyim.el
@@ -1029,42 +1029,6 @@ BUG:拼音无法有效地处理多音字。"
       ;; TODO, 排序个人词库?
       )))
 
-(defun pyim-hanzi2xingma (string scheme-name &optional return-list)
-  "返回汉字 STRING 对应形码方案 SCHEME-NAME 的 code (不包括
-code-prefix)。当RETURN-LIST 设置为 t 时,返回一个 code list。"
-  (let* ((fun (intern (concat "pyim-hanzi2xingma:" (symbol-name scheme-name))))
-         (code (and fun (funcall fun string))))
-    (when code
-      (if return-list
-          (list code)
-        code))))
-
-(defun pyim-hanzi2xingma:wubi (string)
-  "返回汉字 STRING 的五笔编码(不包括 code-prefix)。当RETURN-LIST
-设置为 t 时,返回一个编码列表。"
-  (when (string-match-p "^\\cc+\\'" string)
-    (let ((code (pyim-code-search string 'wubi))
-          (len (length string)))
-      (when (string-empty-p code)
-        (when (= len 1)
-          (error "No code found for %s" string))
-        (setq string (split-string string "" t)
-              code
-              (cl-case len
-                ;; 双字词,分别取两个字的前两个编码
-                (2 (concat (substring (pyim-hanzi2xingma:wubi (nth 0 string)) 
0 2)
-                           (substring (pyim-hanzi2xingma:wubi (nth 1 string)) 
0 2)))
-                ;; 三字词,取前二字的首编码,及第三个字的前两个编码
-                (3 (concat (substring (pyim-hanzi2xingma:wubi (nth 0 string)) 
0 1)
-                           (substring (pyim-hanzi2xingma:wubi (nth 1 string)) 
0 1)
-                           (substring (pyim-hanzi2xingma:wubi (nth 2 string)) 
0 2)))
-                ;; 四字词及以上,分别前三个字及最后一个字的首编码
-                (t (concat (substring (pyim-hanzi2xingma:wubi (nth 0 string)) 
0 1)
-                           (substring (pyim-hanzi2xingma:wubi (nth 1 string)) 
0 1)
-                           (substring (pyim-hanzi2xingma:wubi (nth 2 string)) 
0 1)
-                           (substring (pyim-hanzi2xingma:wubi (nth (1- len) 
string)) 0 1))))))
-      code)))
-
 (defun pyim-create-word-at-point (&optional number silent)
   "将光标前字符数为 NUMBER 的中文字符串添加到个人词库中
 当 SILENT 设置为 t 是,不显示提醒信息。"



reply via email to

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