branch: elpa/helm
commit 9262f9590c0a40f2f3339f10de2463e23659e726
Author: Thierry Volpiatto <thie...@posteo.net>
Commit: Thierry Volpiatto <thie...@posteo.net>

    Simplify loop in helm--collect-pairs-in-string
---
 helm-lib.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/helm-lib.el b/helm-lib.el
index a087d54c65..8c741013a3 100644
--- a/helm-lib.el
+++ b/helm-lib.el
@@ -607,9 +607,12 @@ E.g.: helm.el$
                    ls ""))))
 
 (defsubst helm--collect-pairs-in-string (string)
-  (cl-loop for str on (split-string string "" t) by 'cdr
-           when (cdr str)
-           collect (list (car str) (cadr str))))
+  ;; We want to collect e.g.
+  ;; in "abcd" -> (("a" "b") ("b" "c") ("c" "d"))
+  ;; and not (("a" "b") ("c" "d")) so we use by #'cdr which is the default.
+  ;; If the last pair have no cdr i.e. (s1 nil) ignore it.
+  (cl-loop for (s1 s2) on (split-string string "" t)
+           when s2 collect (list s1 s2)))
 
 ;;; Help routines.
 ;;

Reply via email to