Write a Common Lisp macro to handle this code pattern:
(defun-compile-time check-lambda-list-internal (lambda-list &optional mode) (cond ((null lambda-list)) ((member (first lambda-list) *ordered-lambda-list-keywords* :test #'eq) (check-lambda-list-internal (rest lambda-list) (first lambda-list))) (t (let ((parameter (first lambda-list))) (ecase mode ((nil) (unless (symbolp parameter) (error "Invalid parameter: ~S" parameter))) (&optional (unless (or (symbolp parameter) (and (consp parameter) (null (rest (last parameter))) (or (= (length parameter) 1) (= (length parameter) 2) (and (= (length parameter) 3) (symbolp (third parameter)))) (symbolp (first parameter)))) (error "Invalid &OPTIONAL parameter: ~S" parameter))) (&rest (unless (symbolp parameter) (error "Invalid &REST parameter: ~S" parameter))) (&key (unless (or (symbolp parameter) (and (consp parameter) (null (rest (last parameter))) (or (= (length parameter) 1) (= (length parameter) 2) (and (= (length parameter) 3) (symbolp (third parameter)))) (or (symbolp (first parameter)) (and (consp (first parameter)) (null (rest (last (first parameter)))) (= (length (first parameter)) 2) (symbolp (first (first parameter))) (symbolp (second (first parameter))))))) (error "Invalid &KEY parameter: ~S" parameter))) (&aux (unless (or (symbolp parameter) (and (consp parameter) (null (rest (last parameter))) (or (= (length parameter) 1) (= (length parameter) 2)) (symbolp (first parameter)))) (error "Invalid &AUX parameter: ~S" parameter))))) (check-lambda-list-internal (rest lambda-list) mode))))

Problem: Macro call that should be transformed by defun-compile-time

Macro definition:
(defmacro defun-compile-time (function-name lambda-list &body body)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (cl:defun ,function-name ,lambda-list ,@body)
     (eval-when (:compile-toplevel) (compile ',function-name))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:defun check-lambda-list-internal (lambda-list &optional mode) (cond ((null lambda-list)) ((member (first lambda-list) *ordered-lambda-list-keywords* :test (function eq)) (check-lambda-list-internal (rest lambda-list) (first lambda-list))) (t (let ((parameter (first lambda-list))) (ecase mode ((nil) (unless (symbolp parameter) (error "Invalid parameter: ~S" parameter))) (&optional (unless (or (symbolp parameter) (and (consp parameter) (null (rest (last parameter))) (or (= (length parameter) 1) (= (length parameter) 2) (and (= (length parameter) 3) (symbolp (third parameter)))) (symbolp (first parameter)))) (error "Invalid &OPTIONAL parameter: ~S" parameter))) (&rest (unless (symbolp parameter) (error "Invalid &REST parameter: ~S" parameter))) (&key (unless (or (symbolp parameter) (and (consp parameter) (null (rest (last parameter))) (or (= (length parameter) 1) (= (length parameter) 2) (and (= (length parameter) 3) (symbolp (third parameter)))) (or (symbolp (first parameter)) (and (consp (first parameter)) (null (rest (last (first parameter)))) (= (length (first parameter)) 2) (symbolp (first (first parameter))) (symbolp (second (first parameter))))))) (error "Invalid &KEY parameter: ~S" parameter))) (&aux (unless (or (symbolp parameter) (and (consp parameter) (null (rest (last parameter))) (or (= (length parameter) 1) (= (length parameter) 2)) (symbolp (first parameter)))) (error "Invalid &AUX parameter: ~S" parameter))))) (check-lambda-list-internal (rest lambda-list) mode)))) (eval-when (:compile-toplevel) (compile (quote check-lambda-list-internal))))