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

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

[elpa] externals/dash ba80875 109/439: Nice indentation for --each, --ea


From: Phillip Lord
Subject: [elpa] externals/dash ba80875 109/439: Nice indentation for --each, --each-while and --dotimes
Date: Tue, 04 Aug 2015 20:26:58 +0000

branch: externals/dash
commit ba808759d5a29b7151900366afc7a988bcea6452
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>

    Nice indentation for --each, --each-while and --dotimes
---
 dash.el |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/dash.el b/dash.el
index a3f6855..8eed84a 100644
--- a/dash.el
+++ b/dash.el
@@ -44,6 +44,8 @@
            ,@body)
          (!cdr ,l)))))
 
+(put '--each 'lisp-indent-function 1)
+
 (defun -each (list fn)
   "Calls FN with every item in LIST. Returns nil, used for side-effects only."
   (--each list (funcall fn it)))
@@ -59,6 +61,8 @@
            (if (not ,pred) (setq ,c nil) ,@body))
          (!cdr ,l)))))
 
+(put '--each-while 'lisp-indent-function 2)
+
 (defun -each-while (list pred fn)
   "Calls FN with every item in LIST while (PRED item) is non-nil.
 Returns nil, used for side-effects only."
@@ -71,6 +75,8 @@ Returns nil, used for side-effects only."
        ,@body
        (setq it (1+ it)))))
 
+(put '--dotimes 'lisp-indent-function 1)
+
 (defun -dotimes (num fn)
   "Repeatedly calls FN (presumably for side-effects) passing in integers from 
0 through n-1."
   (--dotimes num (funcall fn it)))
@@ -182,7 +188,8 @@ Thus function FN should return a collection."
   "Anaphoric form of `-first'."
   (let ((n (make-symbol "needle")))
     `(let (,n)
-       (--each-while ,list (not ,n) (when ,form (setq ,n it)))
+       (--each-while ,list (not ,n)
+         (when ,form (setq ,n it)))
        ,n)))
 
 (defun -first (fn list)
@@ -247,9 +254,10 @@ Alias: `-every?'"
 (defun -take (n list)
   "Returns a new list of the first N items in LIST, or all items if there are 
fewer than N."
   (let (result)
-    (--dotimes n (when list
-                   (!cons (car list) result)
-                   (!cdr list)))
+    (--dotimes n
+      (when list
+        (!cons (car list) result)
+        (!cdr list)))
     (nreverse result)))
 
 (defun -drop (n list)



reply via email to

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