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

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

[nongnu] elpa/haskell-tng-mode c3793b2 176/385: canonical until macro


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode c3793b2 176/385: canonical until macro
Date: Tue, 5 Oct 2021 23:59:26 -0400 (EDT)

branch: elpa/haskell-tng-mode
commit c3793b2ca131488c7f325af5af90896ec08c292e
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>

    canonical until macro
---
 haskell-tng-smie.el | 10 +++++-----
 haskell-tng-util.el | 11 +++++------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index a7f396a..fdab67e 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -178,8 +178,8 @@ information, to aid in the creation of new rules."
                        (car (smie-indent-backward-token))))
                (psexp (save-excursion
                         (caddr (haskell-tng:until
-                                (smie-backward-sexp)
-                                (bobp)))))
+                                (or (smie-backward-sexp)
+                                    (bobp))))))
                (next (save-excursion
                        (car (smie-indent-forward-token)))))
 
@@ -409,9 +409,9 @@ extreme parent.
 Inspired by `smie-indent--parent', which can only be used in
 :before and :after."
   (when-let ((res (or (smie-backward-sexp t)
-                     (haskell-tng:until
-                      (smie-backward-sexp)
-                      (bobp))))
+                      (haskell-tng:until
+                       (or (smie-backward-sexp)
+                           (bobp)))))
              (tok (if (car res)
                       ;; break through open parens
                       (car (smie-indent-backward-token))
diff --git a/haskell-tng-util.el b/haskell-tng-util.el
index 2c08e86..15068b7 100644
--- a/haskell-tng-util.el
+++ b/haskell-tng-util.el
@@ -60,14 +60,13 @@ and taking a regexp."
    default-directory
    (lambda (dir) (directory-files dir nil regexp))))
 
-(defmacro haskell-tng:until (form &optional guard)
-  "Runs `while' on FORM until it is non-nil, returning the value.
-
-A guard is provided which may cause the loop to exit early with nil."
+(defmacro haskell-tng:until (test &rest body)
+  ;; https://lists.gnu.org/r/emacs-devel/2018-10/msg00250.html
+  ;; by Stefan Monnier
+  "Run BODY while TEST is non-nil, returning the final TEST."
   (let ((res (gensym "res")))
     `(let (,res)
-       (while (and (not ,guard)
-                   (not (setq ,res ,form))))
+       (while (not (setq ,res ,test)) ,@body)
        ,res)))
 
 (provide 'haskell-tng-util)



reply via email to

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