[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash b0da7b2 093/426: Declare macros before using them.
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash b0da7b2 093/426: Declare macros before using them. |
Date: |
Tue, 04 Aug 2015 19:36:56 +0000 |
branch: externals/dash
commit b0da7b2842230b82ad4c11ff2c564400854a5f9c
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Declare macros before using them.
---
dash.el | 48 ++++++++++++++++++++++++------------------------
1 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/dash.el b/dash.el
index 01469fb..6902559 100644
--- a/dash.el
+++ b/dash.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2012 Magnar Sveen
;; Authors: Magnar Sveen <address@hidden>
-;; Version: 1.0.0
+;; Version: 1.0.1
;; Keywords: lists
;; This program is free software; you can redistribute it and/or modify
@@ -149,6 +149,24 @@ Alias: `-reject'"
Thus function FN should return a collection."
(--mapcat (funcall fn it) list))
+(defmacro --first (form list)
+ "Anaphoric form of `-first'."
+ (let ((l (make-symbol "list"))
+ (n (make-symbol "needle")))
+ `(let ((,l ,list)
+ (,n nil))
+ (while (and ,l (not ,n))
+ (let ((it (car ,l)))
+ (when ,form (setq ,n it)))
+ (setq ,l (cdr ,l)))
+ ,n)))
+
+(defun -first (fn list)
+ "Returns the first x in LIST where (FN x) is non-nil, else nil.
+
+To get the first item in the list no questions asked, use `car'."
+ (--first (funcall fn it) list))
+
(defun ---truthy? (val)
(not (null val)))
@@ -376,6 +394,11 @@ The test for equality is done with `equal',
or with `-compare-fn' if that's non-nil."
(--filter (not (-contains? list2 it)) list))
+(defvar -compare-fn nil
+ "Tests for equality use this function or `equal' if this is nil.
+It should only be set using dynamic scope with a let, like:
+(let ((-compare-fn =)) (-union numbers1 numbers2 numbers3)")
+
(defun -contains? (list element)
"Return whether LIST contains ELEMENT.
The test for equality is done with `equal',
@@ -393,28 +416,5 @@ or with `-compare-fn' if that's non-nil."
(setq lst (cdr lst)))
lst))))))
-(defmacro --first (form list)
- "Anaphoric form of `-first'."
- (let ((l (make-symbol "list"))
- (n (make-symbol "needle")))
- `(let ((,l ,list)
- (,n nil))
- (while (and ,l (not ,n))
- (let ((it (car ,l)))
- (when ,form (setq ,n it)))
- (setq ,l (cdr ,l)))
- ,n)))
-
-(defun -first (fn list)
- "Returns the first x in LIST where (FN x) is non-nil, else nil.
-
-To get the first item in the list no questions asked, use `car'."
- (--first (funcall fn it) list))
-
-(defvar -compare-fn nil
- "Tests for equality use this function or `equal' if this is nil.
-It should only be set using dynamic scope with a let, like:
-(let ((-compare-fn =)) (-union numbers1 numbers2 numbers3)")
-
(provide 'dash)
;;; dash.el ends here
- [elpa] externals/dash 4b5e24b 087/426: Docs: move -any? -all? -none? and -each up., (continued)
- [elpa] externals/dash 4b5e24b 087/426: Docs: move -any? -all? -none? and -each up., Phillip Lord, 2015/08/04
- [elpa] externals/dash f8d74ff 091/426: Docs: update example text to match example code., Phillip Lord, 2015/08/04
- [elpa] externals/dash eacb6f2 092/426: Docs: Better generation of github urls., Phillip Lord, 2015/08/04
- [elpa] externals/dash 8c75026 080/426: Add !drop, Phillip Lord, 2015/08/04
- [elpa] externals/dash a2941cd 097/426: Typo, Phillip Lord, 2015/08/04
- [elpa] externals/dash b9b6330 079/426: Add !take, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6931d8a 094/426: Remove Melpa from installation while waiting for it to be included., Phillip Lord, 2015/08/04
- [elpa] externals/dash 0bd26ac 096/426: Add aliases for -p instead of ?, Phillip Lord, 2015/08/04
- [elpa] externals/dash 38eed45 095/426: Add rainbow-dash, Phillip Lord, 2015/08/04
- [elpa] externals/dash dc6f46c 098/426: Simplify docs-generation using dash., Phillip Lord, 2015/08/04
- [elpa] externals/dash b0da7b2 093/426: Declare macros before using them.,
Phillip Lord <=
- [elpa] externals/dash 4fedd2e 099/426: Add -partition and -partition-all, Phillip Lord, 2015/08/04
- [elpa] externals/dash 79b56cc 101/426: Use --each, !cons and !cdr to simplify implementations., Phillip Lord, 2015/08/04
- [elpa] externals/dash a08fc14 102/426: Add -each-while, Phillip Lord, 2015/08/04
- [elpa] externals/dash 49512b9 107/426: Simplify -take and -drop with --dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash ed47814 105/426: Add -dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash eb50d17 106/426: Add Melpa back in., Phillip Lord, 2015/08/04
- [elpa] externals/dash 0e5c69b 089/426: Docs: more concise example for anaphoric functions., Phillip Lord, 2015/08/04
- [elpa] externals/dash 03370ea 108/426: Simplify examples-to-docs and examples-to-tests with dash, Phillip Lord, 2015/08/04
- [elpa] externals/dash ba80875 109/426: Nice indentation for --each, --each-while and --dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash f1c8453 083/426: Rename to dash., Phillip Lord, 2015/08/04