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

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

[elpa] externals/pyim 976f7f4 5/5: 添加 pyim-flatten-tree, 旧版本的 Emacs 没有


From: ELPA Syncer
Subject: [elpa] externals/pyim 976f7f4 5/5: 添加 pyim-flatten-tree, 旧版本的 Emacs 没有 flatten-tree.
Date: Wed, 8 Dec 2021 00:57:31 -0500 (EST)

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

    添加 pyim-flatten-tree, 旧版本的 Emacs 没有 flatten-tree.
---
 pyim-common.el | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/pyim-common.el b/pyim-common.el
index f6af740..5158da3 100644
--- a/pyim-common.el
+++ b/pyim-common.el
@@ -102,10 +102,24 @@ When CARE-FIRST-ONE is no-nil, ((a b c) (d e)) => (a d)."
                      (append x (make-list (- n (length x)) nil)))
                    lists)))
       (delete-dups
-       (flatten-tree
+       (pyim-flatten-tree
         (apply #'cl-mapcar
                #'list lists))))))
 
+(if (fboundp 'flatten-tree)
+    (defalias 'pyim-flatten-tree 'flatten-tree)
+  (defun pyim-flatten-tree (tree)
+    "Take TREE and \"flatten\" it."
+    (let (elems)
+      (while (consp tree)
+        (let ((elem (pop tree)))
+          (while (consp elem)
+            (push (cdr elem) tree)
+            (setq elem (car elem)))
+          (if elem (push elem elems))))
+      (if tree (push tree elems))
+      (nreverse elems))))
+
 (defun pyim-subconcat (list &optional sep)
   "Concat sublist of LIST with SEP: (a b c d) => (abcd abc ab)."
   (let ((n (length list))



reply via email to

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