From fac42338bbf0f89fe6c8a9367cf5b9ba96eff422 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sat, 21 Mar 2026 13:10:07 +0100 Subject: [PATCH] Make member-if compiler-macro hygienic * lisp/subr.el (member-if): Use uninterned symbol in compiler-macro (bug#80647). --- lisp/subr.el | 3 ++- test/lisp/subr-tests.el | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lisp/subr.el b/lisp/subr.el index 1f5819e299e..a1d718ca5b7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1226,7 +1226,8 @@ with (member-if (lambda (x) (foo (bar x))) items)" (declare (compiler-macro (lambda (_) - `(drop-while (lambda (x) (not (funcall ,pred x))) ,list)))) + (let ((x (make-symbol "x"))) + `(drop-while (lambda (,x) (not (funcall ,pred ,x))) ,list))))) (drop-while (lambda (x) (not (funcall pred x))) list)) ;; This is good to have for improved readability in certain uses, but diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index b6cabb4ec2a..3d4f524d630 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -1715,6 +1715,18 @@ final or penultimate step during initialization.")) (should (equal (funcall (subr--identity #'any) #'minusp ls) '(-1 -2 -3))) (should (equal (funcall (subr--identity #'any) #'stringp ls) nil)))) +(defun subr-tests--any-memql (x xs) + "Like `memql', but exercising the `compiler-macro' of `any'. +The argument names are important." + (any (lambda (y) (eql x y)) xs)) + +(ert-deftest subr-any-compiler-macro () + "Test `compiler-macro' of `any'." + (let ((xs (number-sequence 0 4))) + (dotimes (x (1+ (length xs))) + (should (eq (subr-tests--any-memql x xs) + (memql x xs)))))) + (ert-deftest total-line-spacing () (progn (let ((line-spacing 10))