From 176a61738c8f393f288946d6142b5fdc1809921c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 2 Dec 2014 16:18:06 -0500 Subject: [PATCH] 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 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 364d28e1bb7..c76a721565a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,6 +1,9 @@ 2014-12-02 Eric S. Raymond - * 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 6ce02b79a0a..4cc80e9be6f 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, -- 2.39.2