j14i/cl-macros huggingface dataset:
Write a Common Lisp macro to handle this code pattern:
(builder (:session :store (make-redis-store :namespace *namespace* :connection *connection*)) (lambda (env) (unless (gethash :user (getf env :lack.session)) (setf (gethash :user (getf env :lack.session)) "深町英太郎")) (unless (gethash :counter (getf env :lack.session)) (setf (gethash :counter (getf env :lack.session)) 0)) `(200 (:content-type "text/plain") (,(format nil "Hello, ~A! You've been here for ~Ath times!" (gethash :user (getf env :lack.session)) (incf (gethash :counter (getf env :lack.session))))))))

Problem: Macro call that should be transformed by builder

Macro definition:
(defmacro builder (&rest app-or-middlewares)
  (let ((middlewares (butlast app-or-middlewares)))
    `(reduce #'funcall
             (remove-if
              #'null
              (list
               ,@(loop for mw in middlewares
                       when mw
                         collect (convert-to-middleware-form mw))))
             :initial-value (to-app ,(car (last app-or-middlewares)))
             :from-end t)))

Macroexpansion:
(reduce (function funcall) (remove-if (function null) (list (lambda (#:app240) (funcall (find-middleware :session) #:app240 :store (make-redis-store :namespace *namespace* :connection *connection*))))) :initial-value (to-app (lambda (env) (unless (gethash :user (getf env :lack.session)) (setf (gethash :user (getf env :lack.session)) "深町英太郎")) (unless (gethash :counter (getf env :lack.session)) (setf (gethash :counter (getf env :lack.session)) 0)) (sb-int:quasiquote (200 (:content-type "text/plain") (#S(sb-impl::comma :expr (format nil "Hello, ~A! You've been here for ~Ath times!" (gethash :user (getf env :lack.session)) (incf (gethash :counter (getf env :lack.session)))) :kind 0)))))) :from-end t)
Write a Common Lisp macro to handle this code pattern:
(defmethod* 'some-name)

Problem: Macro call that should be transformed by DEFMETHOD*

Macro definition:
(defmacro DEFMETHOD* ...)

Macroexpansion:
(let* ((#:some-name131 (ensure-generic*-function ''some-name))
       (temp-method (defmethod #:some-name130))
       (actual-gf
        (ensure-generic*-function ''some-name :lambda-list
                                  (sb-mop:generic-function-lambda-list
                                   (symbol-function '#:some-name130))
                                  :special-variables 'nil))
       (actual-method
        (add-method* #:some-name131
                     (make-instance 'method* :special-variables (list)
                                    :qualifiers 'nil :specializers
                                    (sb-mop:method-specializers temp-method)
                                    :lambda-list
                                    (sb-mop:method-lambda-list temp-method)
                                    :documentation
                                    (documentation temp-method t) :function
                                    (sb-mop:method-function temp-method)))))
  (declare (ignorable #:some-name131)
           (ignore actual-gf))
  (setf (documentation actual-method t) (documentation temp-method t))
  actual-method)
Write a Common Lisp macro to handle this code pattern:
(var 'some-name)

Problem: Macro call that should be transformed by VAR

Macro definition:
(defmacro VAR ...)

Macroexpansion:
(defparameter 'some-name nil)
Define a macro that eliminates this repetitive pattern:
(continue-whopper nil (progn))

Issue: Macro call that should be transformed by CONTINUE-WHOPPER

Macro definition:
(defmacro CONTINUE-WHOPPER ...)

Macroexpansion:
(call-next-method-fn self class-env inst-env mcs%caller mcs%next-methods
                     (list nil (progn)))
Create a Common Lisp macro for the following transformation. Before code:
;; eval loses lexical environment - can't access surrounding bindings
(let ((x 1))
  (eval '(+ 1 x)))  ;; Error: X is unbound!

;; Need: way to tunnel lexical variables into eval

What needs to change: eval cannot access lexical environment — want a 'tunnel' that bridges lexical scope into eval's dynamic world

Macro definition:
(defvar pandoric-eval-tunnel)

(defmacro pandoric-eval (vars expr)
  `(let ((pandoric-eval-tunnel
           (plambda () ,vars t)))
     (eval `(with-pandoric
              ,',vars pandoric-eval-tunnel
              ,,expr))))

Macroexpansion:
;; (let ((x 1))
;;   (pandoric-eval (x)
;;     '(+ 1 x)))
;; => 2
;;
;; (let ((x 1))
;;   (pandoric-eval (x)
;;     '(incf x))
;;   x)
;; => 2  ;; modifications persist!
;;
;; Builds a plambda capturing x, then eval-with-pandoric
;; reconstructs x as symbol-macrolet inside eval
Write a Common Lisp macro to handle this code pattern:
(without-c-dependency (tv))

Problem: Macro call that should be transformed by without-c-dependency

Macro definition:
(defmacro without-c-dependency (&body body)
  ` (let (*depender*)
      ,@body))

Macroexpansion:
(let (*depender*) (tv))
Generate a defmacro form that transforms code like this:
(js nil nil)

Pattern to recognize: Macro call that should be transformed by JS

Macro definition:
(defmacro JS ...)

Macroexpansion:
(ps
  nil
  nil)
Generate a defmacro form that transforms code like this:
(ematch0 args (nil nil) ((list* '&optional rest) (list* '&optional (process-optional-args rest))) ((list* '&key rest) (list* '&key (process-keyword-args rest))) ((list* '&rest rest) (list* '&rest (process-rest-args rest))) ((list* '&aux rest) args) ((list* thing rest) (list* thing (process-lambda-args rest))))

Pattern to recognize: Macro call that should be transformed by ematch0

Macro definition:
(defmacro ematch0 (what &body clauses)
  `(match0 ,what
     ,@clauses
     (_ (error "level0 match error!"))))

Macroexpansion:
(match0 args (nil nil) ((list* (quote &optional) rest) (list* (quote &optional) (process-optional-args rest))) ((list* (quote &key) rest) (list* (quote &key) (process-keyword-args rest))) ((list* (quote &rest) rest) (list* (quote &rest) (process-rest-args rest))) ((list* (quote &aux) rest) args) ((list* thing rest) (list* thing (process-lambda-args rest))) (_ (error "level0 match error!")))
You are a Common Lisp macro expert. Given this code pattern:
(with-special-initargs 'some-name)

Write a macro that addresses: Macro call that should be transformed by WITH-SPECIAL-INITARGS

Macro definition:
(defmacro WITH-SPECIAL-INITARGS ...)

Macroexpansion:
(funcall-with-special-initargs (list (list . quote) (list . some-name))
                               (lambda ()))
Define a macro that eliminates this repetitive pattern:
(defproto nil (progn))

Issue: Macro call that should be transformed by DEFPROTO

Macro definition:
(defmacro DEFPROTO ...)

Macroexpansion:
(progn
 (declaim (special nil))
 (eval-when (:compile-toplevel))
 (setf (symbol-value 'nil)
         (ensure-object (when (boundp 'nil) (symbol-value 'nil)) (list progn)
                        :properties (list) :nickname 'nil)))
You are a Common Lisp macro expert. Given this code pattern:
(when (eql (top-sign) 'skip-first-list-init) (pop-sign))

Write a macro that addresses: Macro call that should be transformed by when

Macro definition:
(defmacro when (test &body forms)
  `(if ,test
	   ,(cl:if (cadr forms)
			   `(progn ,@forms)
			   (car forms))))

Macroexpansion:
(if (eql (top-sign) (quote skip-first-list-init)) (pop-sign))
Generate a defmacro form that transforms code like this:
(with-active-layers 'some-name)

Pattern to recognize: Macro call that should be transformed by WITH-ACTIVE-LAYERS

Macro definition:
(defmacro WITH-ACTIVE-LAYERS ...)

Macroexpansion:
(dynamic-wind
  :proceed
  #:proceed182
  (%with-active-layers 'some-name
    (#:proceed182)))
Create a Common Lisp macro for the following transformation. Before code:
(define-simple-definition-resolver symbol-macro (designator) (sb-int:info :variable :macro-expansion designator))

What needs to change: Macro call that should be transformed by define-simple-definition-resolver

Macro definition:
(defmacro define-simple-definition-resolver (class lookup-function &body body)
  (let ((package (gensym "PACKAGE")))
    `(define-definition-resolver ,class (,class ,package)
       (when (ignore-errors ,(if body
                                 `(let ((,(first lookup-function) ,class))
                                    ,@body)
                                 `(,lookup-function ,class)))
         (list (make-instance ',class :designator ,class :package ,package))))))

Macroexpansion:
(define-definition-resolver symbol-macro (symbol-macro #:package146) (when (ignore-errors (let ((designator symbol-macro)) (sb-int:info :variable :macro-expansion designator))) (list (make-instance (quote symbol-macro) :designator symbol-macro :package #:package146))))
Create a Common Lisp macro for the following transformation. Before code:
(deferror "42704" unrecognized-configuration-parameter data-exception)

What needs to change: Macro call that should be transformed by deferror

Macro definition:
(defmacro deferror (code typename &optional (superclass 'database-error))
  `(progn (define-condition ,typename (,superclass) ())
          (setf (gethash ,code *error-table*) ',typename)))

Macroexpansion:
(progn (define-condition unrecognized-configuration-parameter (data-exception) nil) (setf (gethash "42704" *error-table*) (quote unrecognized-configuration-parameter)))
You are a Common Lisp macro expert. Given this code pattern:
(answer foo 23)

Write a macro that addresses: Macro call that should be transformed by answer

Macro definition:
(defmacro answer (call &body forms)
  (let ((name (if (listp call) (car call) call))
        (sym (gensym)))
    `(if-called
      ',name
      (let ((,sym (fdefinition ',name)))
        (declare (ignorable ,sym))
        (let ((times 0))
          (lambda (&rest args)
            (declare (ignorable args))
            ,(let ((cases
                     `(case (prog1 times (incf times))
                        ,.(loop
                            for i from 0
                            for (form . rest) on forms
                            collect `(,(if rest i T) ,form)))))
               (if (listp call)
                   `(trivia:match args
                     ((list . ,(cdr call)) ,cases)
                     (_ (unhandled)))
                   cases))))))))

Macroexpansion:
(if-called (quote foo) (let ((#:g159 (fdefinition (quote foo)))) (declare (ignorable #:g159)) (let ((times 0)) (lambda (&rest args) (declare (ignorable args)) (case (prog1 times (incf times)) (t 23))))))
Generate a defmacro form that transforms code like this:
(dreletf nil
  nil)

Pattern to recognize: Macro call that should be transformed by DRELETF

Macro definition:
(defmacro DRELETF ...)

Macroexpansion:
(let ((#:symbol-store232
       (with-symbol-access
         (list))))
  (special-symbol-reprogv #:symbol-store232
      (list)
    (locally (declare (special)) nil)))
Generate a defmacro form that transforms code like this:
(define-op (:like infix-op))

Pattern to recognize: Macro call that should be transformed by define-op

Macro definition:
(defmacro define-op ((op-name struct-type &key sql-op-name include-slots (package (find-package '#:sxql/operator))) &body body)
  (check-type op-name symbol)
  (let ((struct-name (intern (concatenate 'string (symbol-name op-name) #.(string :-op)) package)))
    `(defstruct (,struct-name (:include ,struct-type
                               (name ,(or sql-op-name
                                          (with-output-to-string (s)
                                            (loop for c across (symbol-name op-name)
                                                  if (char= c #\-)
                                                    do (write-char #\Space s)
                                                  else
                                                    do (write-char c s)))))
                               ,@include-slots)
                              (:constructor ,(intern (concatenate 'string
                                                                  #.(string :make-)
                                                                  (symbol-name op-name)
                                                                  #.(string :-op))
                                                     package)
                                  ,(ecase struct-type
                                     ((unary-op
                                       unary-splicing-op
                                       unary-postfix-op) '(var))
                                     ((infix-op
                                       infix-splicing-op
                                       infix-list-op) '(left right))
                                     (conjunctive-op '(&rest expressions)))))
       ,@body)))

Macroexpansion:
(defstruct (like-op (:include infix-op (name "LIKE")) (:constructor make-like-op (left right))))
Write a Common Lisp macro to handle this code pattern:
(make-simple-collector-to-place 'some-name)

Problem: Macro call that should be transformed by MAKE-SIMPLE-COLLECTOR-TO-PLACE

Macro definition:
(defmacro MAKE-SIMPLE-COLLECTOR-TO-PLACE ...)

Macroexpansion:
(progn
 (setf 'some-name (alexandria:ensure-list 'some-name))
 (let* ((#:tail124 (last 'some-name)))
   (lambda (&rest values)
     (collect-at-end 'some-name #:tail124 values)
     'some-name)))
Define a macro that eliminates this repetitive pattern:
(any-of nil
  (progn))

Issue: Macro call that should be transformed by ANY-OF

Macro definition:
(defmacro ANY-OF ...)

Macroexpansion:
(lc (nil (progn)) thereis)
Create a Common Lisp macro for the following transformation. Before code:
(set-custom-vars :integer #'parse-number :real #'parse-number :boolean #'json-boolean-to-lisp :beginning-of-array #'init-accumulator :array-member #'accumulator-add :end-of-array #'accumulator-get-sequence :array-type 'list :beginning-of-object #'init-accumulator :object-key #'accumulator-add-key :object-value #'accumulator-add-value :end-of-object #'accumulator-get :beginning-of-string #'init-string-stream-accumulator :string-char #'string-stream-accumulator-add :end-of-string #'string-stream-accumulator-get :aggregate-scope (union *aggregate-scope-variables* '(*accumulator* *accumulator-last*)) :internal-decoder #'decode-json)

What needs to change: Macro call that should be transformed by set-custom-vars

Macro definition:
(defmacro set-custom-vars (&rest key-args)
  `(setq
    ,@(loop for (supplied-key value) on key-args by #'cddr
         append (loop for (var . var-key) in *custom-vars*
                   thereis (if (eql var-key supplied-key)
                               (list var value))))))

Macroexpansion:
(setq *integer-handler* (function parse-number) *real-handler* (function parse-number) *boolean-handler* (function json-boolean-to-lisp) *beginning-of-array-handler* (function init-accumulator) *array-member-handler* (function accumulator-add) *end-of-array-handler* (function accumulator-get-sequence) *json-array-type* (quote list) *beginning-of-object-handler* (function init-accumulator) *object-key-handler* (function accumulator-add-key) *object-value-handler* (function accumulator-add-value) *end-of-object-handler* (function accumulator-get) *beginning-of-string-handler* (function init-string-stream-accumulator) *string-char-handler* (function string-stream-accumulator-add) *end-of-string-handler* (function string-stream-accumulator-get) *aggregate-scope-variables* (union *aggregate-scope-variables* (quote (*accumulator* *accumulator-last*))) *internal-decoder* (function decode-json))
Define a macro that eliminates this repetitive pattern:
(dynamic-let* nil)

Issue: Macro call that should be transformed by DYNAMIC-LET*

Macro definition:
(defmacro DYNAMIC-LET* ...)

Macroexpansion:
(progn)
Write a Common Lisp macro to handle this code pattern:
(parse-conjunctive-clauses client instance t :var (parse-d-spec client :type-spec *placeholder-result*))

Problem: Macro call that should be transformed by parse-conjunctive-clauses

Macro definition:
(defmacro parse-conjunctive-clauses (client region read-name-p &rest args)
  (with-unique-names (clauses next)
    `(prog (,clauses)
      ,next
        (push (do-parse-clause ,client ,region *index* ,read-name-p ,@args)
              ,clauses)
        (when (maybe-parse-token :keywords '(:and))
          (go ,next))
        (return (nreverse ,clauses)))))

Macroexpansion:
(prog (#:clauses124) #:next125 (push (do-parse-clause client instance *index* t :var (parse-d-spec client :type-spec *placeholder-result*)) #:clauses124) (when (maybe-parse-token :keywords (quote (:and))) (go #:next125)) (return (nreverse #:clauses124)))
Write a Common Lisp macro to handle this code pattern:
(define-type-dispatch nil
    (progn))

Problem: Macro call that should be transformed by DEFINE-TYPE-DISPATCH

Macro definition:
(defmacro DEFINE-TYPE-DISPATCH ...)

Macroexpansion:
(progn
 (defun nil (progn)
   (declare (optimize speed (debug 1) (safety 1) (compilation-speed 0)))
   (etypecase progn))
 (sb-c:defknown nil
     ((or))
     (or)
     (sb-c:any)
   :overwrite-fndb-silently
   t))
Write a Common Lisp macro to handle this code pattern:
(quasiquote-unexpand-1 'unquote-splicing el)

Problem: Macro call that should be transformed by quasiquote

Macro definition:
(defmacro quasiquote (x) (quasiquote-expand x))

Macroexpansion:
(quasiquote-unexpand-1 (quote unquote-splicing) el)
Write a Common Lisp macro to handle this code pattern:
(aecase (car x) (:y :no) (:x (list it :yes)))

Problem: Macro call that should be transformed by aecase

Macro definition:
(defmacro aecase (keyform &body cases)
  "Like ECASE, except binds the result of the keyform to IT (via LET) for the
scope of the cases."
  `(anaphoric ecase ,keyform ,@cases))

Macroexpansion:
(anaphoric ecase (car x) (:y :no) (:x (list it :yes)))
Define a macro that eliminates this repetitive pattern:
(collect-and 'some-name)

Issue: Macro call that should be transformed by COLLECT-AND

Macro definition:
(defmacro COLLECT-AND ...)

Macroexpansion:
(common-lisp:let* ((#:generator-501 (generator 'some-name))
                   #:bools-497
                   (#:bool-498 t))
  (declare (type generator #:generator-501))
  (tagbody
   #:ll-502
    (setq #:bools-497 (next-in #:generator-501 (go end)))
    (if (null (setq #:bool-498 #:bools-497))
        (go end))
    (go #:ll-502)
   end)
  #:bool-498)
Create a Common Lisp macro for the following transformation. Before code:
(cache-dir #p"/tmp/clache-test/")

What needs to change: Macro call that should be transformed by cache

Macro definition:
(defmacro cache ((keyargs &key store expire) function-definition-form)
  "Annotation for caching functions with their arguments. This should
be used with CL-ANNOT. KEYARGS is a form or a list of form for making
a cache key.  To make cache keys distinct as to the function, you may
add a keyword or a symbol into KEYARGS. See also WITH-CACHE.

Example:

    @cache ((:f x y z))
    (defun f (x y z)
      ...)
    
    ;; Remove a cache of F
    (remcache '(:f 1 2 3))"
  (replace-function-body
   (lambda (name lambda-list body)
     @ignore name
     @ignore lambda-list
     (let ((key (if (listp keyargs)
                    `(list ,@keyargs)
                    keyargs)))
       `(with-cache (,key :store ,store :expire ,expire)
          ,@body)))
   function-definition-form))

Macroexpansion:
(cache-dir #P"/tmp/clache-test/")
Write a Common Lisp macro to handle this code pattern:
(ps-html nil nil)

Problem: Macro call that should be transformed by PS-HTML

Macro definition:
(defmacro PS-HTML ...)

Macroexpansion:
(stringify nil nil)
Define a macro that eliminates this repetitive pattern:
(signal-syntax-error* error-pos "Comment group not closed.")

Issue: Macro call that should be transformed by signal-syntax-error*

Macro definition:
(defmacro signal-syntax-error* (pos format-control &rest format-arguments)
  `(error 'ppcre-syntax-error
          :pos ,pos
          :format-control ,format-control
          :format-arguments (list ,@format-arguments)))

Macroexpansion:
(error (quote ppcre-syntax-error) :pos error-pos :format-control "Comment group not closed." :format-arguments (list))
You are a Common Lisp macro expert. Given this code pattern:
(dynamic-wind
  nil
  :key
  nil)

Write a macro that addresses: Macro call that should be transformed by DYNAMIC-WIND

Macro definition:
(defmacro DYNAMIC-WIND ...)

Macroexpansion:
(flet ((#:dynamic-wind-thunk225 (#:proceed-thunk226)
         (macrolet ((proceed (&body #:proceed-body227)
                      `(if ,'#:proceed-thunk226
                           (funcall (the function ,'#:proceed-thunk226))
                           (progn ,@#:proceed-body227))))
           nil
           :key
           nil)))
  (declare (inline #:dynamic-wind-thunk225))
  (let ((*dynamic-wind-stack*
         (cons #'#:dynamic-wind-thunk225 *dynamic-wind-stack*)))
    (#:dynamic-wind-thunk225 nil)))
Generate a defmacro form that transforms code like this:
(define-path-instruction-pair move-to "M" (x y))

Pattern to recognize: Macro call that should be transformed by define-path-instruction-pair

Macro definition:
(defmacro define-path-instruction-pair (name instruction (&rest args))
  (let ((draw-relative (intern (concatenate 'string (string name) "-R"))))
    `(progn
       (defun ,name (,@args)
         (format-instruction ,instruction ,@args))
       (defun ,draw-relative (,@args)
         (format-instruction ,(string-downcase instruction) ,@args)))))

Macroexpansion:
(progn (defun move-to (x y) (format-instruction "M" x y)) (defun move-to-r (x y) (format-instruction "m" x y)))
Write a Common Lisp macro to handle this code pattern:
(define-port-value-slot nil nil)

Problem: Macro call that should be transformed by DEFINE-PORT-VALUE-SLOT

Macro definition:
(defmacro DEFINE-PORT-VALUE-SLOT ...)

Macroexpansion:
(progn
 (defmethod port-value ((nil nil)) (slot-value nil nil))
 (defmethod (setf port-value) (value (nil nil))
   (setf (slot-value nil nil) value))
 (defmethod port-value-boundp ((nil nil)) (slot-boundp nil 'nil))
 (defmethod port-value-makunbound ((nil nil)) (slot-makunbound nil 'nil)))
Generate a defmacro form that transforms code like this:
(defcategory-fn (my-category-keyword) '(or :debug :info))

Pattern to recognize: Macro call that should be transformed by defcategory

Macro definition:
(defmacro defcategory (category &optional expands-as set)
  `(defcategory-fn ',category ',expands-as ,set))

Macroexpansion:
(defcategory-fn (my-category-keyword) (quote (or :debug :info)))
Write a Common Lisp macro to handle this code pattern:
(when (and (not (equal identifier name-string)) (find :hyphen *enabled-warnings*)) (warn "Possible ambiguity through hyphen override of ~s" check-name))

Problem: Macro call that should be transformed by when

Macro definition:
(defmacro when (test &body forms)
  `(if ,test
	   ,(cl:if (cadr forms)
			   `(progn ,@forms)
			   (car forms))))

Macroexpansion:
(if (and (not (equal identifier name-string)) (find :hyphen *enabled-warnings*)) (warn "Possible ambiguity through hyphen override of ~s" check-name))
Generate a defmacro form that transforms code like this:
(define-error no-function-returns () (name return-set) "Function '~a' did not specify any return types" name)

Pattern to recognize: Macro call that should be transformed by define-error

Macro definition:
(defmacro define-error (name (&key (error-type 'varjo-error) (prefix "Varjo"))
                            (&rest args) error-string &body body)
  `(defcondition ,name (:error-type ,error-type :prefix ,prefix) ,args
       ,error-string ,@body))

Macroexpansion:
(defcondition no-function-returns (:error-type varjo-error :prefix "Varjo") (name return-set) "Function '~a' did not specify any return types" name)