From e8ecf65cf96d2d9bd56190cc17b1b83ce7b940f7 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 21 Jul 2019 19:11:43 +0200 Subject: [PATCH] core-lib: add pushmany! macro, refactor pushnew! --- core/core-lib.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index 2dc21ace7..fc2130496 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -284,10 +284,18 @@ MATCH is a string regexp. Only entries that match it will be included." (directory-file-name (file-name-directory path)))) (defmacro pushnew! (place &rest values) - "Like `cl-pushnew', but will prepend VALUES to PLACE. -The order VALUES is preserved." - `(dolist (--x-- (list ,@(nreverse values))) - (cl-pushnew --x-- ,place))) + "Push VALUES sequentially into PLACE, if they aren't already present. +This is a variadic `cl-pushnew'." + (let ((var (make-symbol "result"))) + `(dolist (,var (list ,@values)) + (cl-pushnew ,var ,place)))) + +(defmacro pushmany! (place &rest values) + "Push VALUES sequentually into PLACE. +This is a variadic `push'." + (let ((var (make-symbol "result"))) + `(dolist (,var ,values) + (push ,var ,place)))) (defmacro prependq! (sym &rest lists) "Prepend LISTS to SYM in place."