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

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

[elpa] externals/pyim 0758baa 2/2: Use string-join.


From: ELPA Syncer
Subject: [elpa] externals/pyim 0758baa 2/2: Use string-join.
Date: Mon, 13 Dec 2021 21:57:25 -0500 (EST)

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

    Use string-join.
    
        * pyim-candidates.el (pyim-candidates-create:quanpin)
        (pyim-candidates-create-quanpin):
    
        * pyim.el (pyim-select-word:pinyin):
    
        * pyim-pymap.el (pyim-pymap-sort-pymap, pyim-pymap-build-pymap):
    
        * pyim-punctuation.el (pyim-punctuation-translate):
    
        * pyim-process.el (pyim-process-create-code-criteria):
    
        * pyim-pinyin.el (pyim-pinyin-shuangpin-invalid-pinyin-regexp):
    
        * pyim-page.el (pyim-page-preview-create:quanpin)
        (pyim-page-preview-create:shuangpin, pyim-page-menu-create):
    
        * pyim-liberime.el (pyim-liberime-create-word)
        (pyim-liberime-get-code):
    
        * pyim-dregcache.el (pyim-dregcache-sort-icode2word):
    
        * pyim-cstring.el (pyim-cstring-split-to-string-1)
        (pyim-cstring-to-pinyin):
    
        * pyim-cregexp.el (pyim-cregexp-build-1)
        (pyim-cregexp-build:xingma):
    
        * pyim-common.el (pyim-subconcat):
---
 pyim-candidates.el  | 28 ++++++++++------------------
 pyim-common.el      |  2 +-
 pyim-cregexp.el     | 34 ++++++++++++++++------------------
 pyim-cstring.el     |  4 ++--
 pyim-dregcache.el   |  2 +-
 pyim-liberime.el    | 22 +++++++++-------------
 pyim-page.el        | 30 ++++++++++++------------------
 pyim-pinyin.el      | 28 ++++++++++++++--------------
 pyim-process.el     |  6 +++---
 pyim-punctuation.el |  2 +-
 pyim-pymap.el       | 20 +++++++++-----------
 pyim.el             | 10 ++++------
 12 files changed, 82 insertions(+), 106 deletions(-)

diff --git a/pyim-candidates.el b/pyim-candidates.el
index 88f7948..c2ee97a 100644
--- a/pyim-candidates.el
+++ b/pyim-candidates.el
@@ -94,9 +94,7 @@ IMOBJS 获得候选词条。"
   (if async
       ;; 构建一个搜索中文的正则表达式, 然后使用这个正则表达式在当前 buffer 中搜
       ;; 索词条。
-      (let ((str (mapconcat #'identity
-                            (pyim-codes-create (car imobjs) scheme-name)
-                            "")))
+      (let ((str (string-join (pyim-codes-create (car imobjs) scheme-name))))
         (if (< (length str) 1)
             pyim-candidates
           ;; NOTE: 让第一个词保持不变是不是合理,有待进一步的观察。
@@ -155,16 +153,14 @@ IMOBJS 获得候选词条。"
                (> (length (car imobjs)) 1))
       (dolist (imobj imobjs)
         (let* ((w (pyim-dcache-get
-                   (mapconcat #'identity
-                              (pyim-codes-create imobj scheme-name 1)
-                              "-")
+                   (string-join (pyim-codes-create imobj scheme-name 1) "-")
                    '(ishortcode2word)))
-               (regexp1 (mapconcat #'identity
-                                   (pyim-codes-create imobj scheme-name)
-                                   "-"))
-               (regexp2 (mapconcat #'identity
-                                   (pyim-codes-create imobj scheme-name)
-                                   "[^-]*-"))
+               (regexp1 (string-join
+                         (pyim-codes-create imobj scheme-name)
+                         "-"))
+               (regexp2 (string-join
+                         (pyim-codes-create imobj scheme-name)
+                         "[^-]*-"))
                (w1 (cl-remove-if-not
                     (lambda (cstr)
                       (let ((py (pyim-cstring-to-pinyin cstr nil "-")))
@@ -181,17 +177,13 @@ IMOBJS 获得候选词条。"
     (dolist (imobj imobjs)
       (let* (;; 个人词条
              (w1 (pyim-dcache-get
-                  (mapconcat #'identity
-                             (pyim-codes-create imobj scheme-name)
-                             "-")
+                  (string-join (pyim-codes-create imobj scheme-name) "-")
                   (if pyim-enable-shortcode
                       '(icode2word ishortcode2word)
                     '(icode2word))))
              ;; 词库词条
              (w2 (pyim-dcache-get
-                  (mapconcat #'identity
-                             (pyim-codes-create imobj scheme-name)
-                             "-")
+                  (string-join (pyim-codes-create imobj scheme-name) "-")
                   (if pyim-enable-shortcode
                       '(code2word shortcode2word)
                     '(code2word))))
diff --git a/pyim-common.el b/pyim-common.el
index 7b421d3..25b386e 100644
--- a/pyim-common.el
+++ b/pyim-common.el
@@ -126,7 +126,7 @@ When CARE-FIRST-ONE is no-nil, ((a b c) (d e)) => (a d)."
         output)
     (dotimes (i (- n 1))
       (let ((list (cl-subseq list 0 (- n i))))
-        (push (mapconcat #'identity list (or sep "")) output)))
+        (push (string-join list (or sep "")) output)))
     (nreverse output)))
 
 (defun pyim-char-before-to-string (num)
diff --git a/pyim-cregexp.el b/pyim-cregexp.el
index 2a999a1..51a3ef2 100644
--- a/pyim-cregexp.el
+++ b/pyim-cregexp.el
@@ -137,9 +137,7 @@ regexp, 所以搜索单字的时候一般可以搜到生僻字,但搜索句子
                   imobjs))
                 (regexp
                  (when regexp-list
-                   (mapconcat #'identity
-                              (delq nil regexp-list)
-                              "\\|")))
+                   (string-join (delq nil regexp-list) "\\|")))
                 (regexp
                  (if chinese-only
                      regexp
@@ -187,21 +185,21 @@ regexp, 所以搜索单字的时候一般可以搜到生僻字,但搜索句子
                                         first-equal _all-equal code-prefix)
   "从 IMOBJ 创建一个搜索中文的 regexp."
   (cl-flet ((build-regexp
-             (list)
-             (let* ((n (apply #'max (mapcar #'length list)))
-                    results)
-               (dotimes (i n)
-                 (push (format "[%s]%s"
-                               (mapconcat
-                                (lambda (x)
-                                  (if (> i (- (length x) 1))
-                                      ""
-                                    (char-to-string
-                                     (elt x i))))
-                                list "")
-                               (if (> i 0) "?" ""))
-                       results))
-               (mapconcat #'identity (reverse results) ""))))
+              (list)
+              (let* ((n (apply #'max (mapcar #'length list)))
+                     results)
+                (dotimes (i n)
+                  (push (format "[%s]%s"
+                                (mapconcat
+                                 (lambda (x)
+                                   (if (> i (- (length x) 1))
+                                       ""
+                                     (char-to-string
+                                      (elt x i))))
+                                 list "")
+                                (if (> i 0) "?" ""))
+                        results))
+                (string-join (reverse results)))))
     (let ((regexp (mapconcat
                    (lambda (x)
                      (let ((code (concat (or code-prefix "")
diff --git a/pyim-cstring.el b/pyim-cstring.el
index 149379d..f6d170d 100644
--- a/pyim-cstring.el
+++ b/pyim-cstring.el
@@ -176,7 +176,7 @@ CHINESE-STRING 分词,得到一个词条 alist,这个 alist 的元素都是
         (push (or separator " ") result))
       (push (substring chinese-string i (1+ i)) result))
     (setq result (nreverse result))
-    (mapconcat #'identity result "")))
+    (string-join result)))
 
 (defun pyim-cstring-split-buffer ()
   "将一个 buffer 中的中文文章,进行分词操作。"
@@ -259,7 +259,7 @@ BUG: 当 STRING 中包含其它标点符号,并且设置 SEPERATER 时,结
                              pinyins-list))))
         (if return-list
             list
-          (mapconcat #'identity list " "))))))
+          (string-join list " "))))))
 
 ;;;###autoload
 (defalias 'pyim-hanzi2pinyin-simple 'pyim-cstring-to-pinyin-simple)
diff --git a/pyim-dregcache.el b/pyim-dregcache.el
index ba8d07e..667a1ea 100644
--- a/pyim-dregcache.el
+++ b/pyim-dregcache.el
@@ -89,7 +89,7 @@
         ;; ((string-match "^\\([a-z]+ \\|[a-z]+-[a-z]+ \\|[a-z]+-[a-z]+-[a-z]+ 
\\)\\(.*\\)" l)
         (let* ((pinyin (match-string 1 l))
                (words (pyim-dregcache-sort-words (split-string (match-string 2 
l) " "))))
-          (insert (format "%s\n" (concat pinyin (mapconcat #'identity words " 
"))))))
+          (insert (format "%s\n" (concat pinyin (string-join words " "))))))
        ;; 其他词
        ((string= l "")
         ;; skip empty line
diff --git a/pyim-liberime.el b/pyim-liberime.el
index 3afb2ac..5d0d140 100644
--- a/pyim-liberime.el
+++ b/pyim-liberime.el
@@ -205,7 +205,7 @@
              (not (cl-find-if-not #'stringp codes))
              (not (cl-find-if-not #'stringp words)))
     (liberime-clear-composition)
-    (dolist (key (string-to-list (mapconcat #'identity codes "")))
+    (dolist (key (string-to-list (string-join codes)))
       (liberime-process-key key))
     (let (word)
       (while (setq word (pop words))
@@ -236,13 +236,12 @@ Please see: https://github.com/rime/librime/issues/349";
   (cond
    ;; 处理基于语音的输入法,比如:拼音,这类输入法 preedit 一般用空格
    ;; 分隔,与汉字一一对应。
-   ((string-match-p
-     (mapconcat #'identity
-                '("pinyin" "luna" "terra" "bopomofo" "stenotype"
-                  "jyut6ping3" "wugniu" "soutzoe" "zyenpheng"
-                  "sampheng" "clover")
-                "\\|")
-     (alist-get 'schema_id (liberime-get-status)))
+   ((string-match-p (string-join
+                     '("pinyin" "luna" "terra" "bopomofo" "stenotype"
+                       "jyut6ping3" "wugniu" "soutzoe" "zyenpheng"
+                       "sampheng" "clover")
+                     "\\|")
+                    (alist-get 'schema_id (liberime-get-status)))
     (unless (liberime-get-preedit)
       (liberime-search input 1))
     (let* ((n (length word))
@@ -257,11 +256,8 @@ Please see: https://github.com/rime/librime/issues/349";
             (setq i 0)
           (setq i (- i 1))))
       str))
-   ((string-match-p
-     (mapconcat #'identity
-                '("wubi86" "wubi98")
-                "\\|")
-     (alist-get 'schema_id (liberime-get-status)))
+   ((string-match-p (string-join '("wubi86" "wubi98") "\\|")
+                    (alist-get 'schema_id (liberime-get-status)))
     (let ((lst (split-string (liberime-get-preedit) "[ ']+"))
           (str "")
           words)
diff --git a/pyim-page.el b/pyim-page.el
index 399b724..aca628e 100644
--- a/pyim-page.el
+++ b/pyim-page.el
@@ -295,12 +295,10 @@ page 的概念,比如,上面的 “nihao” 的 *待选词列表* 就可以
 
 (defun pyim-page-preview-create:quanpin (&optional separator)
   (let* ((separator (or separator " "))
-         (translated (mapconcat #'identity
-                                (mapcar
-                                 (lambda (w)
-                                   (concat (nth 0 w) (nth 1 w)))
-                                 (car pyim-imobjs))
-                                separator)))
+         (translated (string-join (mapcar (lambda (w)
+                                            (concat (nth 0 w) (nth 1 w)))
+                                          (car pyim-imobjs))
+                                  separator)))
     (concat
      ;; | 显示光标位置的字符
      (pyim-entered-with-entered-buffer
@@ -340,20 +338,18 @@ page 的概念,比如,上面的 “nihao” 的 *待选词列表* 就可以
                         (car x)))
                     keymaps))
            result))))
-    (mapconcat #'identity
-               (reverse result)
-               (or separator " "))))
+    (string-join (reverse result) (or separator " "))))
 
 (defun pyim-page-preview-create:xingma (&optional separator)
   (let* ((scheme-name (pyim-scheme-name)))
     (cl-flet* ((segment (x)
-                        (mapconcat #'identity
-                                   (car (pyim-imobjs-create x scheme-name))
-                                   (or separator " ")))
+                 (string-join
+                  (car (pyim-imobjs-create x scheme-name))
+                  (or separator " ")))
                (fmt (x)
-                    (mapconcat #'segment
-                               (split-string x "'")
-                               "'")))
+                 (mapconcat #'segment
+                            (split-string x "'")
+                            "'")))
       ;; | 显示光标位置的字符
       (pyim-process-with-entered-buffer
         (if (equal (point) (point-max))
@@ -380,9 +376,7 @@ page 的概念,比如,上面的 “nihao” 的 *待选词列表* 就可以
                       'face 'pyim-page-selection))
            (format "%d.%s " i str))
          result)))
-    (mapconcat #'identity
-               (nreverse result)
-               (or separator ""))))
+    (string-join (nreverse result) (or separator ""))))
 
 (defun pyim-page-style:two-lines (page-info)
   "将 PAGE-INFO 格式化为选词框中显示的字符串.
diff --git a/pyim-pinyin.el b/pyim-pinyin.el
index 6a3baae..b32b331 100644
--- a/pyim-pinyin.el
+++ b/pyim-pinyin.el
@@ -58,20 +58,20 @@
 
 (defconst pyim-pinyin-shuangpin-invalid-pinyin-regexp
   (format "^\\(%s\\)$"
-          (mapconcat #'identity
-                     '("[qtghkzcsdn]o"
-                       "[ypfbmw]uo"
-                       "[qj]ong"
-                       "[rtysdghklzcn]iong"
-                       "[qtypdjlxbnm]uai"
-                       "[ghk]ing?"
-                       "[qjlxn]uang"
-                       "[dgh]iang"
-                       "[qjlx]ua"
-                       "[hkg]ia"
-                       "[rtsdghkzc]v"
-                       "[jl]ui")
-                     "\\|"))
+          (string-join
+           '("[qtghkzcsdn]o"
+             "[ypfbmw]uo"
+             "[qj]ong"
+             "[rtysdghklzcn]iong"
+             "[qtypdjlxbnm]uai"
+             "[ghk]ing?"
+             "[qjlxn]uang"
+             "[dgh]iang"
+             "[qjlx]ua"
+             "[hkg]ia"
+             "[rtsdghkzc]v"
+             "[jl]ui")
+           "\\|"))
   "双拼可能自动产生的无效拼音. 例如输入 kk 得到有效拼音 kuai .
 但同时产生了无效拼音 king .  用户手动输入的无效拼音无需考虑.
 因为用户有即时界面反馈,不可能连续输入无效拼音.")
diff --git a/pyim-process.el b/pyim-process.el
index db90b33..1d3a601 100644
--- a/pyim-process.el
+++ b/pyim-process.el
@@ -518,9 +518,9 @@ alist 列表。"
 (defun pyim-process-create-code-criteria ()
   "创建 `pyim-cstring-to-code-criteria'."
   (setq pyim-cstring-to-code-criteria
-        (let ((str (mapconcat #'identity
-                              (pyim-codes-create (car 
(pyim-process-get-imobjs)) (pyim-scheme-name))
-                              "")))
+        (let ((str (string-join
+                    (pyim-codes-create (car (pyim-process-get-imobjs))
+                                       (pyim-scheme-name)))))
           (if (> (length pyim-cstring-to-code-criteria)
                  (length str))
               pyim-cstring-to-code-criteria
diff --git a/pyim-punctuation.el b/pyim-punctuation.el
index 7ab4313..1c724a6 100644
--- a/pyim-punctuation.el
+++ b/pyim-punctuation.el
@@ -186,7 +186,7 @@ If you don't like this function, set the variable to nil")
               (if (= position 0)
                   (push punct result)
                 (push (car puncts) result))))))))
-    (insert (mapconcat #'identity (reverse result) ""))
+    (insert (string-join (reverse result)))
     (backward-char rnum)))
 
 (defun pyim-punctuation-return-proper-punct (punc-list &optional before)
diff --git a/pyim-pymap.el b/pyim-pymap.el
index 313ead1..b0a3493 100644
--- a/pyim-pymap.el
+++ b/pyim-pymap.el
@@ -843,10 +843,9 @@ If FORCE is non-nil, FORCE build."
   (let (pymap)
     (dolist (py pyim-pymap)
       (push (list (car py)
-                  (mapconcat #'identity
-                             (sort (split-string (cadr py) "")
-                                   #'pyim-pymap-cchar<)
-                             ""))
+                  (string-join
+                   (sort (split-string (cadr py) "")
+                         #'pyim-pymap-cchar<)))
             pymap))
     (reverse pymap)))
 
@@ -886,13 +885,12 @@ If FORCE is non-nil, FORCE build."
                                       'sep t))
                         (list 4000 7000 n)))
                  (string
-                  (mapconcat #'identity
-                             (mapcar (lambda (str)
-                                       (if (get-text-property 0 'sep str)
-                                           "|"
-                                         str))
-                                     (sort (append seps value) 
#'pyim-pymap-cchar<))
-                             "")))
+                  (string-join
+                   (mapcar (lambda (str)
+                             (if (get-text-property 0 'sep str)
+                                 "|"
+                               str))
+                           (sort (append seps value) #'pyim-pymap-cchar<)))))
             (insert (format "(%S %S)\n" key string))))
         hash-table)
        (sort-lines nil (point-min) (point-max))
diff --git a/pyim.el b/pyim.el
index c972a6a..27b655c 100644
--- a/pyim.el
+++ b/pyim.el
@@ -526,12 +526,10 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
          ;; pyim-imobjs 包含 *pyim-entered-buffer* 里面光标前面的字符
          ;; 串,通过与 selected-word 做比较,获取光标前未转换的字符串。
          ;; to-be-translated.
-         (to-be-translated (mapconcat #'identity
-                                      (mapcar
-                                       (lambda (w)
-                                         (concat (nth 2 w) (nth 3 w)))
-                                       (nthcdr length-selected-word imobj))
-                                      "")))
+         (to-be-translated
+          (string-join (mapcar (lambda (w)
+                                 (concat (nth 2 w) (nth 3 w)))
+                               (nthcdr length-selected-word imobj)))))
     ;; 大体来说,entered 字符串可以分解为三个部分:
 
     ;; 1. 光标前字符串



reply via email to

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