From d62766305ad8fe6ca1695341c34b9836d051e3cb Mon Sep 17 00:00:00 2001 From: Mattias EngdegÄrd Date: Wed, 13 Jul 2022 13:46:52 +0200 Subject: Add `take` and `ntake` (bug#56521) These are useful list primitives, complementary to `nthcdr`. * src/fns.c (Ftake, Fntake): New. (syms_of_fns): Defsubr them. * doc/lispref/lists.texi (List Elements): * lisp/emacs-lisp/shortdoc.el (list): Document. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns, pure-fns): Declare `take` pure and side-effect-free. * test/src/fns-tests.el (fns-tests--take-ref, fns--take-ntake): New test. * etc/NEWS: Announce. --- lisp/emacs-lisp/shortdoc.el | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lisp/emacs-lisp/shortdoc.el') diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el index a2d954cadbb..1514ece6d1f 100644 --- a/lisp/emacs-lisp/shortdoc.el +++ b/lisp/emacs-lisp/shortdoc.el @@ -595,6 +595,10 @@ A FUNC form can have any number of `:no-eval' (or `:no-value'), :eval (nth 1 '(one two three))) (nthcdr :eval (nthcdr 1 '(one two three))) + (take + :eval (take 3 '(one two three four))) + (ntake + :eval (ntake 3 (list 'one 'two 'three 'four))) (elt :eval (elt '(one two three) 1)) (car-safe -- cgit v1.2.3