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

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

[elpa] externals/capf-autosuggest fc5384e 3/4: Rewrite cl-loop in terms


From: ELPA Syncer
Subject: [elpa] externals/capf-autosuggest fc5384e 3/4: Rewrite cl-loop in terms of a while loop
Date: Thu, 4 Nov 2021 19:57:17 -0400 (EDT)

branch: externals/capf-autosuggest
commit fc5384eb17c1add26cfd6161a833fd5abe65225b
Author: jakanakaevangeli <jakanakaevangeli@chiru.no>
Commit: jakanakaevangeli <jakanakaevangeli@chiru.no>

    Rewrite cl-loop in terms of a while loop
---
 capf-autosuggest.el | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/capf-autosuggest.el b/capf-autosuggest.el
index 520408d..b3a6ecd 100644
--- a/capf-autosuggest.el
+++ b/capf-autosuggest.el
@@ -589,23 +589,26 @@ Is only applicable if point is after the last prompt."
      (lambda (input predicate action)
        (pcase action
          ((or 't (and 'nil (guard capf-autosuggest-all-completions-only-one)))
-          (cl-loop
-           with only-one = capf-autosuggest-all-completions-only-one
-           with regexps = completion-regexp-list
-           for i below (ring-size ring)
-           for elem = (ring-ref ring i)
-           if (string-prefix-p input elem)
-           if (cl-loop for regex in regexps
-                       always (string-match-p regex elem))
-           if (or (null predicate)
-                  (funcall predicate elem))
-           if only-one
-           if action
-           return (list elem)
-           else
-           return elem
-           end
-           else collect elem))
+          (let ((only-one capf-autosuggest-all-completions-only-one)
+                (regexps completion-regexp-list)
+                (ring-length (ring-length ring))
+                (i 0)
+                elem ret)
+            (while (< i ring-length)
+              (setq elem (ring-ref ring i))
+              (and (string-prefix-p input elem)
+                   (cl-loop for regex in regexps
+                            always (string-match-p regex elem))
+                   (or (null predicate)
+                       (funcall predicate elem))
+                   (if only-one
+                       (setq ret (if action (list elem) elem)
+                             i ring-length)
+                     (push elem ret)))
+              (cl-incf i))
+            (if (listp ret)
+                (nreverse ret)
+              ret)))
          ('nil
           (complete-with-action
            nil (let ((capf-autosuggest-all-completions-only-one nil))



reply via email to

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