[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 176a617: Add filter macro, which does what you expe
From: |
Eric S. Raymond |
Subject: |
[Emacs-diffs] master 176a617: Add filter macro, which does what you expect. |
Date: |
Tue, 02 Dec 2014 21:19:21 +0000 |
branch: master
commit 176a61738c8f393f288946d6142b5fdc1809921c
Author: Eric S. Raymond <address@hidden>
Commit: Eric S. Raymond <address@hidden>
Add filter macro, which does what you expect.
* subr.el (filter): New macro. Because it's just silly for a Lisp not
to have this in 2014. And VC mode needs it.
---
lisp/ChangeLog | 5 ++++-
lisp/subr.el | 5 +++++
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 364d28e..c76a721 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,6 +1,9 @@
2014-12-02 Eric S. Raymond <address@hidden>
- * vc.el, all backends: API simplification: Abolish dir-status.
+ * subr.el (filter): New macro. Because it's just silly for a Lisp
+ not to have this in 2014. And VC needs it.
+
+ * vc.el, all backends: API simplification: Abolish dir-status.
It's replaced by dir-status-files.
* vc.el, all backends: API simplification: Remove 4th
diff --git a/lisp/subr.el b/lisp/subr.el
index 6ce02b7..4cc80e9 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -222,6 +222,11 @@ Then evaluate RESULT to get return value, default nil.
,@(if (cdr (cdr spec))
`((setq ,(car spec) nil) ,@(cdr (cdr spec))))))))
+(defmacro filter (condp lst)
+ "Return the list consisting of elements in LST for which CONDP is not nil."
+ `(delq nil
+ (mapcar (lambda (x) (and (funcall ,condp x) x)) ,lst)))
+
(defmacro dotimes (spec &rest body)
"Loop a certain number of times.
Evaluate BODY with VAR bound to successive integers running from 0,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 176a617: Add filter macro, which does what you expect.,
Eric S. Raymond <=