branch: externals/compat commit 694647ff667706812d8b3e3c0cd795541673f765 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
compat-30: Add drop --- NEWS.org | 1 + compat-30.el | 2 ++ compat-tests.el | 6 ++++++ compat.texi | 7 +++++++ 4 files changed, 16 insertions(+) diff --git a/NEWS.org b/NEWS.org index c7ca3bef14..15e5e7b576 100644 --- a/NEWS.org +++ b/NEWS.org @@ -7,6 +7,7 @@ - compat-30: Add extended =copy-tree= with support for copying records with non-nil optional second argument. - compat-30: New macro =static-if=. +- compat-30: New alias =drop=. - compat-30: New function =merge-ordered-lists=. - compat-30: New variables =completion-lazy-hilit= and =completion-lazy-hilit-fn= and new function =completion-lazy-hilit=. diff --git a/compat-30.el b/compat-30.el index cd9ad76ea1..4d9c5b1e74 100644 --- a/compat-30.el +++ b/compat-30.el @@ -136,6 +136,8 @@ details." ;;;; Defined in subr.el +(compat-defalias drop nthcdr) ;; <compat-tests:drop> + (compat-defun merge-ordered-lists (lists &optional error-function) ;; <compat-tests:merge-ordered-lists> "Merge LISTS in a consistent order. LISTS is a list of lists of elements. diff --git a/compat-tests.el b/compat-tests.el index d88542526b..6270f8c227 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -957,6 +957,12 @@ (should-equal '(1 2) (take 5 '(1 2))) (should-equal '(1 2 3) (take 3 '(1 2 3 4)))) +(ert-deftest compat-drop () + (static-if (< emacs-major-version 30) ;; TODO reenable if available on CI + (progn + (should-not (drop 5 nil)) + (should-equal '(3 4 5) (drop 2 '(1 2 3 4 5)))))) + (ert-deftest compat-format-message () (should-equal (format-message "a=%s b=%s" 1 2) "a=1 b=2")) diff --git a/compat.texi b/compat.texi index 68ae8766b9..825f348e8e 100644 --- a/compat.texi +++ b/compat.texi @@ -3350,6 +3350,13 @@ older than 30.1. Note that due to upstream changes, it might happen that there will be the need for changes, so use these functions with care. +@c based on lispref/lists.texi +@defun drop n list +This function is an alias for @code{nthcdr}. It returns the @var{n}th +@sc{cdr} of @var{list}. In other words, it skips past the first +@var{n} links of @var{list} and returns what follows. +@end defun + @defun get-truename-buffer filename Return the buffer with @code{file-truename} equal to @var{filename} (a string). If there is no such live buffer, return nil.