[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/helm 7251b1a085 1/2: Avoid duplicated code for helm-iter-l
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/helm 7251b1a085 1/2: Avoid duplicated code for helm-iter-list and helm-iter-circular |
Date: |
Sat, 23 Jul 2022 02:58:39 -0400 (EDT) |
branch: elpa/helm
commit 7251b1a08580d88fbd3c4f61e6b36bc45bf1bf90
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Avoid duplicated code for helm-iter-list and helm-iter-circular
---
helm-lib.el | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/helm-lib.el b/helm-lib.el
index 50d87e6bdf..87c070c202 100644
--- a/helm-lib.el
+++ b/helm-lib.el
@@ -452,21 +452,21 @@ found in SEQ."
else return index
finally return ls)))
-(defun helm-iter-list (seq)
- "Return an iterator object from SEQ."
+(defun helm-iter-list (seq &optional cycle)
+ "Return an iterator object from SEQ.
+The iterator die and return nil when it reach end of SEQ.
+When CYCLE is specified the iterator never ends."
(let ((lis seq))
(lambda ()
(let ((elm (car lis)))
- (setq lis (cdr lis))
+ (setq lis (if cycle
+ (or (cdr lis) seq)
+ (cdr lis)))
elm))))
(defun helm-iter-circular (seq)
"Infinite iteration on SEQ."
- (let ((lis seq))
- (lambda ()
- (let ((elm (car lis)))
- (setq lis (pcase lis (`(,_ . ,ll) (or ll seq))))
- elm))))
+ (helm-iter-list seq 'cycle))
(cl-defun helm-iter-sub-next-circular (seq elm &key (test 'eq))
"Infinite iteration of SEQ starting at ELM."