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

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

[elpa] externals/pyim 126dae5fd7 7/7: Simplify pyim-cstring-to-pinyin


From: ELPA Syncer
Subject: [elpa] externals/pyim 126dae5fd7 7/7: Simplify pyim-cstring-to-pinyin
Date: Fri, 13 Jan 2023 23:58:04 -0500 (EST)

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

    Simplify pyim-cstring-to-pinyin
---
 pyim-cstring.el | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/pyim-cstring.el b/pyim-cstring.el
index 527ba62932..7ddd406e98 100644
--- a/pyim-cstring.el
+++ b/pyim-cstring.el
@@ -112,35 +112,31 @@ BUG: 当 STRING 中包含其它标点符号,并且设置 SEPERATER 时,结
       (if return-list
           (list string)
         string)
-    (let (pinyins-list)
-      ;; ("Hello" "银" "行") -> (("Hello") ("yin") ("hang" "xing"))
-      (setq pinyins-list
+    (let* ((pinyins-list
+            ;; ("Hello" "银" "行") -> (("Hello") ("yin") ("hang" "xing"))
             (mapcar (lambda (str)
                       (if (pyim-string-match-p "\\cc" str)
                           (pyim-pymap-cchar2py-get str)
                         (list str)))
                     (pyim-cstring--partition string t)))
-
-      ;; 通过排列组合的方式, 重排 pinyins-list。
-      ;; 比如:(("Hello") ("yin") ("hang")) -> (("Hello" "yin" "hang"))
-      (setq pinyins-list
-            (pyim-permutate-list
-             (pyim-cstring--adjust-duoyinzi
-              string pinyins-list)))
-
+           ;; 通过排列组合的方式, 重排 pinyins-list。
+           ;; 比如:(("Hello") ("yin") ("hang")) -> (("Hello" "yin" "hang"))
+           (pinyins-list (pyim-permutate-list
+                          (pyim-cstring--adjust-duoyinzi
+                           string pinyins-list)))
+           (list (mapcar (lambda (x)
+                           (mapconcat (lambda (str)
+                                        (if shou-zi-mu
+                                            (substring str 0 1)
+                                          str))
+                                      x separator))
+                         (if ignore-duo-yin-zi
+                             (list (car pinyins-list))
+                           pinyins-list))))
       ;; 返回拼音字符串或者拼音列表
-      (let ((list (mapcar (lambda (x)
-                            (mapconcat (lambda (str)
-                                         (if shou-zi-mu
-                                             (substring str 0 1)
-                                           str))
-                                       x separator))
-                          (if ignore-duo-yin-zi
-                              (list (car pinyins-list))
-                            pinyins-list))))
-        (if return-list
-            list
-          (string-join list " "))))))
+      (if return-list
+          list
+        (string-join list " ")))))
 
 (defun pyim-cstring--adjust-duoyinzi (word pinyins-list)
   "根据 WORD 对 PINYINS-LIST 进行校正。



reply via email to

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