Add macro seq-setq.

* doc/lispref/sequences.texi (seq-setq): Document this macro.

* lisp/emacs-lisp/seq.el (seq-setq): New macro.

* test/lisp/emacs-lisp/seq-tests.el (test-seq-setq):
Test this macro (bug#50053).
This commit is contained in:
Earl Hyatt 2021-08-14 14:17:12 +02:00 committed by Lars Ingebrigtsen
parent adb6c3f1a4
commit c58f8dda2b
3 changed files with 49 additions and 0 deletions

View file

@ -383,6 +383,30 @@ Evaluate BODY for each created sequence.
(should (null b))
(should (null c)))))
(ert-deftest test-seq-setq ()
(with-test-sequences (seq '(1 2 3 4))
(let (a b c d e)
(seq-setq (a b c d e) seq)
(should (= a 1))
(should (= b 2))
(should (= c 3))
(should (= d 4))
(should (null e)))
(let (a b others)
(seq-setq (a b &rest others) seq)
(should (= a 1))
(should (= b 2))
(should (same-contents-p others (seq-drop seq 2)))))
(let ((a)
(seq '(1 (2 (3 (4))))))
(seq-setq (_ (_ (_ (a)))) seq)
(should (= a 4)))
(let (seq a b c)
(seq-setq (a b c) seq)
(should (null a))
(should (null b))
(should (null c))))
(ert-deftest test-seq-min-max ()
(with-test-sequences (seq '(4 5 3 2 0 4))
(should (= (seq-min seq) 0))