diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2024-05-05 21:26:25 +0200 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2024-05-05 21:31:29 +0200 |
| commit | 694647ff667706812d8b3e3c0cd795541673f765 (patch) | |
| tree | b2e13ec49e5e989763b3d41e06d23ee329f79e72 | |
| parent | d08ecc3191c527247d918c43a86ec99c4059e2f9 (diff) | |
compat-30: Add drop
| -rw-r--r-- | NEWS.org | 1 | ||||
| -rw-r--r-- | compat-30.el | 2 | ||||
| -rw-r--r-- | compat-tests.el | 6 | ||||
| -rw-r--r-- | compat.texi | 7 |
4 files changed, 16 insertions, 0 deletions
@@ -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 cd9ad76..4d9c5b1 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 d885425..6270f8c 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 68ae876..825f348 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. |
