* lisp/subr.el (member-if): Fix compiler macro multiple evaluation.
Problem reported by Pip Cet <pipcet@protonmail.com>.
This commit is contained in:
@@ -1226,8 +1226,13 @@ with
|
||||
(member-if (lambda (x) (foo (bar x))) items)"
|
||||
(declare (compiler-macro
|
||||
(lambda (_)
|
||||
(let ((x (make-symbol "x")))
|
||||
`(drop-while (lambda (,x) (not (funcall ,pred ,x))) ,list)))))
|
||||
(let* ((x (make-symbol "x"))
|
||||
(f (and (not (internal--effect-free-fun-arg-p pred))
|
||||
(make-symbol "f")))
|
||||
(form `(drop-while (lambda (,x)
|
||||
(not (funcall ,(or f pred) ,x)))
|
||||
,list)))
|
||||
(if f `(let ((,f ,pred)) ,form) form)))))
|
||||
(drop-while (lambda (x) (not (funcall pred x))) list))
|
||||
|
||||
;; This is good to have for improved readability in certain uses, but
|
||||
|
||||
@@ -1725,7 +1725,11 @@ The argument names are important."
|
||||
(let ((xs (number-sequence 0 4)))
|
||||
(dotimes (x (1+ (length xs)))
|
||||
(should (eq (subr-tests--any-memql x xs)
|
||||
(memql x xs))))))
|
||||
(memql x xs)))))
|
||||
(let ((n 0))
|
||||
(any (prog1 (lambda (x) (eq x 5)) (incf n))
|
||||
(number-sequence 0 4))
|
||||
(should (eq n 1))))
|
||||
|
||||
(ert-deftest total-line-spacing ()
|
||||
(progn
|
||||
|
||||
Reference in New Issue
Block a user