j14i/cl-macros huggingface dataset:
You are a Common Lisp macro expert. Given this code pattern:
(with-env [plist :e])

Write a macro that addresses: Macro call that should be transformed by with-env

Macro definition:
(defmacro with-env (&body body)
  (let ((body-value (gensym)))
    `(let (,body-value)
       (defclass foo () ((a :initform 3)))
       (defmethod get-val ((object foo) &rest slot/s) (slot-value object (car slot/s)))
       (defmethod (setf get-val) (new-value (object foo) &rest slot/s)
         (setf (slot-value object (car slot/s)) new-value))
       (defstruct bar a)
       (setq ,body-value
             (let ((str (alexandria:copy-array "abcde"))
                   (vec (alexandria:copy-array #(a b c d e)))
                   (arr (alexandria:copy-array #2A((1 2 3)
                                                   (4 5 6))))
                   (list      (copy-list '(a b c d e)))
                   (ht        (eval (read-from-string "{'a 'b 'c 'd}")))
                   (ht-eq     (eval (read-from-string "{eq \"a\" 1
                                                    \"b\" 2}")))
                   (ht-equalp (eval (read-from-string "{equalp '(1 2 3) \"a\"
                                                               '(4 5 6) \"b\"}")))
                   (assoc-list (copy-tree '((a . 1) (b . 2))))
                   (plist      (copy-list '(:a 4 :c 5)))
                   (clos-object (make-instance 'foo))
                   (struct      (make-bar :a 3)))
               (declare (ignorable str vec arr list ht ht-eq ht-equalp
                                   assoc-list plist clos-object struct))
               ,@body))
       (setf (find-class 'foo nil) nil)
       (setf (find-class 'bar nil) nil)
       ,body-value))

Macroexpansion:
(let (#:g130) (defclass foo nil ((a :initform 3))) (defmethod get-val ((object foo) &rest slot/s) (slot-value object (car slot/s))) (defmethod (setf get-val) (new-value (object foo) &rest slot/s) (setf (slot-value object (car slot/s)) new-value)) (defstruct bar a) (setq #:g130 (let ((str (alexandria:copy-array "abcde")) (vec (alexandria:copy-array #(a b c d e))) (arr (alexandria:copy-array #2A((1 2 3) (4 5 6)))) (list (copy-list (quote (a b c d e)))) (ht (eval (read-from-string "{'a 'b 'c 'd}"))) (ht-eq (eval (read-from-string "{eq \"a\" 1
                                                    \"b\" 2}"))) (ht-equalp (eval (read-from-string "{equalp '(1 2 3) \"a\"
                                                               '(4 5 6) \"b\"}"))) (assoc-list (copy-tree (quote ((a . 1) (b . 2))))) (plist (copy-list (quote (:a 4 :c 5)))) (clos-object (make-instance (quote foo))) (struct (make-bar :a 3))) (declare (ignorable str vec arr list ht ht-eq ht-equalp assoc-list plist clos-object struct)) [plist :e])) (setf (find-class (quote foo) nil) nil) (setf (find-class (quote bar) nil) nil) #:g130)
Create a Common Lisp macro for the following transformation. Before code:
(sor (gethash key table) (setf it default))

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

Macro definition:
(defmacro sor (first &rest rest)
  "Like OR, except binds the first argument to IT (via SYMBOL-MACROLET) for
the scope of the rest of the arguments. IT can be set with SETF."
  `(symbolic or ,first ,@rest))

Macroexpansion:
(symbolic or (gethash key table) (setf it default))
Create a Common Lisp macro for the following transformation. Before code:
(with-wcs-math-error-handling (ret (sqrt x)) (check-wcs-math-result))

What needs to change: Macro call that should be transformed by with-wcs-math-error-handling

Macro definition:
(defmacro with-wcs-math-error-handling
    ((var-or-var-list
      (function x &optional (y nil y-supplied-p))
      &rest keyargs
      &key underflow-value)
     &body body)
  (declare (ignorable underflow-value))
  (let ((x_ (gensym)) (y_ (gensym)) (args_ (gensym))
        (var-list (ensure-list var-or-var-list)))
    `(let* ((,x_ ,x)
            (,y_ ,y)
            (,args_ (list ,x_ ,@(if y-supplied-p `(,y_)))))
       (declare (ignorable ,y_)
                (type list ,args_)
                (dynamic-extent ,args_))
       (catch 'return-from-with-wcs-math-error-handling
         (multiple-value-bind ,var-list
             (call-with-wcs-math-error-handler ',function ,args_
                                               ,@keyargs)
           (flet ((check-wcs-math-result
                      (&optional (ret ,(first var-list))
                                 (arg-list ,args_))
                    (check-wcs-math-result ret arg-list)))
             ,@body))))))

Macroexpansion:
(let* ((#:g239 x) (#:g240 nil) (#:g241 (list #:g239))) (declare (ignorable #:g240) (type list #:g241) (dynamic-extent #:g241)) (catch (quote return-from-with-wcs-math-error-handling) (multiple-value-bind (ret) (call-with-wcs-math-error-handler (quote sqrt) #:g241) (flet ((check-wcs-math-result (&optional (ret ret) (arg-list #:g241)) (check-wcs-math-result ret arg-list))) (check-wcs-math-result)))))
Write a Common Lisp macro to handle this code pattern:
(some->> nil (progn))

Problem: Macro call that should be transformed by SOME->>

Macro definition:
(defmacro SOME->> ...)

Macroexpansion:
(let* ((#:g127 nil))
  (if (null #:g127)
      nil
      (->> #:g127 (progn))))
Generate a defmacro form that transforms code like this:
(defclass/a dbd-mysql-connection (dbi-connection) ())

Pattern to recognize: Macro call that should be transformed by defclass/a

Macro definition:
(defmacro defclass/a (name superclasses slots &rest class-options)
  `(progn
     (defclass ,name ,superclasses ,slots ,@class-options)
     (deftype ,(intern (format nil "<~A>" (symbol-name name))) () ',name)
     (setf (find-class ',(intern (format nil "<~A>" (symbol-name name))))
           (find-class ',name))))

Macroexpansion:
(progn (defclass dbd-mysql-connection (dbi-connection) nil) (deftype <dbd-mysql-connection> nil (quote dbd-mysql-connection)) (setf (find-class (quote <dbd-mysql-connection>)) (find-class (quote dbd-mysql-connection))))
Create a Common Lisp macro for the following transformation. Before code:
(with-sql-logging (when exists (execute-sql (sxql:drop-table (sxql:make-sql-symbol (table-name class))))) (mapc #'execute-sql (table-definition class)))

What needs to change: Macro call that should be transformed by with-sql-logging

Macro definition:
(defmacro with-sql-logging (&body body)
  `(let ((*mito-logger-stream* *mito-migration-logger-stream*))
     (with-trace-sql ,@body)))

Macroexpansion:
(let ((*mito-logger-stream* *mito-migration-logger-stream*)) (with-trace-sql (when exists (execute-sql (sxql:drop-table (sxql/sql-type:make-sql-symbol (table-name class))))) (mapc (function execute-sql) (table-definition class))))
Create a Common Lisp macro for the following transformation. Before code:
(scond ((list 'a 'b)))

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

Macro definition:
(defmacro scond (&body clauses)
  "Like COND, except each test-form is bound to IT (via SYMBOL-MACROLET) for the
scope of the corresponsing clause. IT can be set with SETF."
  (labels ((rec (clauses)
	     (if clauses
		 (destructuring-bind ((test &body body) . rest) clauses
		   (if body
		       `(symbolic if ,test (progn ,@body) ,(rec rest))
		       `(symbolic if ,test it ,(rec rest))))
		 nil)))
    (rec clauses)))

Macroexpansion:
(symbolic if (list (quote a) (quote b)) it nil)
Generate a defmacro form that transforms code like this:
(lambda-match
  nil
  nil)

Pattern to recognize: Macro call that should be transformed by LAMBDA-MATCH

Macro definition:
(defmacro LAMBDA-MATCH ...)

Macroexpansion:
(lambda (#:arg147)
  (match #:arg147
    nil
    nil))
You are a Common Lisp macro expert. Given this code pattern:
(print-object/std test)

Write a macro that addresses: Macro call that should be transformed by print-object/std

Macro definition:
(defmacro print-object/std (class)
  "Old name for DEFINE-PRINT-OBJECT/STD."
  `(define-print-object/std ,class))

Macroexpansion:
(define-print-object/std test)
Define a macro that eliminates this repetitive pattern:
(do-iter-values ((item it)) (setf result (funcall f result (funcall key item))))

Issue: Macro call that should be transformed by do-iter-values

Macro definition:
(defmacro do-iter-values ((&rest iters) &body forms)
  "Iterate over the remaining elements of a sequence pointed to by static iterators.

   Evaluate FORMS at each iteration, for each remaining element, until
   one of the iterators reaches the end of the sequence.

   NOTE: May only be used inside a WITH-ITERATORS form.

   ITERS:

     List of bindings. Each element is of the form (PATTERN ITER),
     interpreted as if to WITH-ITER-VALUE, where PATTERN is a binding
     pattern, for the binding to the sequence element value, and ITER
     is a static iterator identifier symbol, introduced in a parent
     WITH-ITERATORS form.

   FORMS

     List of forms evaluated for each remaining element in the
     sequences pointed to by the static iterators.

     At each evaluation the next element of each sequence, pointed by
     each ITER in ITERS, is bound to the variable(s) specified by the
     corresponding PATTERN. After which the iterators are advanced to
     the next elements.

   If one of the iterators has reached the end of its sequence, a
   non-local jump outside the enclosing WITH-ITERATORS form is
   performed, i.e. any forms following this form, within the enclosing
   WITH-ITERATORS form, will not be evaluated."

  (with-gensyms (start)
    `(tagbody
        ,start
        (with-iter-values ,iters ,@forms)
        (go ,start))))

Macroexpansion:
(tagbody #:start172 (with-iter-values ((item it)) (setf result (funcall f result (funcall key item)))) (go #:start172))
Generate a defmacro form that transforms code like this:
(~> nil (list nil))

Pattern to recognize: Macro call that should be transformed by ~>

Macro definition:
(defmacro ~> (&rest body)
  "See flow:concurrently"
  `(concurrently ,@body))

Macroexpansion:
(concurrently nil (list nil))
Write a Common Lisp macro to handle this code pattern:
($> "l" -900)

Problem: Macro call that should be transformed by $

Macro definition:
(defmacro $ (&rest args)
  `(kv ,@args))

Macroexpansion:
($op "$gt" "l" -900)
You are a Common Lisp macro expert. Given this code pattern:
(with-local-readtable)

Write a macro that addresses: Macro call that should be transformed by WITH-LOCAL-READTABLE

Macro definition:
(defmacro WITH-LOCAL-READTABLE ...)

Macroexpansion:
(bind ((*readtable* (copy-readtable *readtable*))))
Define a macro that eliminates this repetitive pattern:
(with-gensyms (value) (setf test (extract-function-name test)) (setf key (extract-function-name key)) (when (and (consp default) (member (first default) '(error cerror))) (setf default `(,@default "No keys match in SWITCH. Testing against ~S with ~S." ,value ',test))) `(let ((,value (,key ,object))) (cond ,@(mapcar (lambda (clause) (if (member (first clause) '(t otherwise)) (progn (when default (error "Multiple default clauses or illegal use of a default clause in ~S." whole)) (setf default `(progn ,@(rest clause))) '(())) (destructuring-bind (key-form &body forms) clause `((,test ,value ,key-form) ,@forms)))) clauses) (t ,default))))

Issue: Macro call that should be transformed by with-gensyms

Macro definition:
(defmacro with-gensyms (names &body forms)
  "Binds a set of variables to gensyms and evaluates the implicit progn FORMS.

Each element within NAMES is either a symbol SYMBOL or a pair (SYMBOL
STRING-DESIGNATOR). Bare symbols are equivalent to the pair (SYMBOL SYMBOL).

Each pair (SYMBOL STRING-DESIGNATOR) specifies that the variable named by SYMBOL
should be bound to a symbol constructed using GENSYM with the string designated
by STRING-DESIGNATOR being its first argument."
  `(let ,(mapcar (lambda (name)
                   (multiple-value-bind (symbol string)
                       (etypecase name
                         (symbol
                          (values name (symbol-name name)))
                         ((cons symbol (cons string-designator null))
                          (values (first name) (string (second name)))))
                     `(,symbol (gensym ,string))))
                 names)
     ,@forms))

Macroexpansion:
(let ((value (gensym #A((5) base-char . "VALUE")))) (setf test (extract-function-name test)) (setf key (extract-function-name key)) (when (and (consp default) (member (first default) (quote (error cerror)))) (setf default (sb-int:quasiquote (#S(sb-impl::comma :expr default :kind 2) "No keys match in SWITCH. Testing against ~S with ~S." #S(sb-impl::comma :expr value :kind 0) (quote #S(sb-impl::comma :expr test :kind 0)))))) (sb-int:quasiquote (let ((#S(sb-impl::comma :expr value :kind 0) (#S(sb-impl::comma :expr key :kind 0) #S(sb-impl::comma :expr object :kind 0)))) (cond #S(sb-impl::comma :expr (mapcar (lambda (clause) (if (member (first clause) (quote (t otherwise))) (progn (when default (error "Multiple default clauses or illegal use of a default clause in ~S." whole)) (setf default (sb-int:quasiquote (progn #S(sb-impl::comma :expr (rest clause) :kind 2)))) (quote (nil))) (destructuring-bind (key-form &body forms) clause (sb-int:quasiquote ((#S(sb-impl::comma :expr test :kind 0) #S(sb-impl::comma :expr value :kind 0) #S(sb-impl::comma :expr key-form :kind 0)) #S(sb-impl::comma :expr forms :kind 2)))))) clauses) :kind 2) (t #S(sb-impl::comma :expr default :kind 0))))))
You are a Common Lisp macro expert. Given this code pattern:
(defparameter* nil nil)

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

Macro definition:
(defmacro DEFPARAMETER* ...)

Macroexpansion:
(defvar/param defparameter nil nil nil)
Define a macro that eliminates this repetitive pattern:
(c? (trc "area running") (* (- (^right)(^left)) (- (^top)(^bottom))))

Issue: Macro call that should be transformed by c?

Macro definition:
(defmacro c? (&body body)
  `(make-c-dependent
    :code ',body
    :value-state :unevaluated
    :rule (c-lambda ,@body)))

Macroexpansion:
(make-c-dependent :code (quote ((trc "area running") (* (- (^right) (^left)) (- (^top) (^bottom))))) :value-state :unevaluated :rule (c-lambda (trc "area running") (* (- (^right) (^left)) (- (^top) (^bottom)))))
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 (format-control &rest format-arguments)
  `(signal-syntax-error* nil ,format-control ,@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:
(action (:after node-lisp) #'propagate-constants-node-lisp)

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

Macro definition:
(defmacro action ((when type &rest args) &body body)
  "Construct an action block, turning `body` into a lambda function
accepting `args` if `args` are provided. If there are no `args`, then
`body` is assumed to be a function object and is used directly with
`when` and `type` to create an `action` instance. Otherwise, the first
argument in `args` is declared to be a node of type `type`, and the
`args` and `body` are used to generate a lambda function."
  (check-type when keyword)
  (check-type type symbol)
  (assert (subtypep type 'node))
  (assert (or (not (endp args)) (= 1 (length body))))
  (if (endp args)
      `(make-action ',when ',type ,@body)
      `(make-action ',when ',type
                    (lambda (,@args)
                      (declare (type ,type ,(first args)))
                      ,@body))))

Macroexpansion:
(make-action (quote :after) (quote node-lisp) (function propagate-constants-node-lisp))
You are a Common Lisp macro expert. Given this code pattern:
(defvar* nil (progn))

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

Macro definition:
(defmacro DEFVAR* ...)

Macroexpansion:
(defvar/param defvar nil (progn) nil)
You are a Common Lisp macro expert. Given this code pattern:
(collect-product nil (progn))

Write a macro that addresses: Macro call that should be transformed by COLLECT-PRODUCT

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

Macroexpansion:
(compiler-let ((*optimize-series-expressions* nil))
              (collect-product nil (progn)))
Generate a defmacro form that transforms code like this:
(iter
  'some-name)

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

Macro definition:
(defmacro ITER ...)

Macroexpansion:
(let* ()
  (block nil
    (block #:iterate142
      (tagbody
        (progn)
       loop-top-nil
        (progn 'some-name)
        (progn)
        (go loop-top-nil)
        (progn))
      nil)))
Create a Common Lisp macro for the following transformation. Before code:
(do-generator (g generator) (unless (funcall predicate g) (yield g)))

What needs to change: Macro call that should be transformed by do-generator

Macro definition:
(defmacro do-generator ((var &rest vars-and-generator) &body body)
  "Steps through the specified generator, binding the value it returns to var, then executing the body for each step. If multiple variables are specified and the generator returns multiple values, the extra values will be bound to the extra variables."
  (let ((g (gensym)))
    `(let ((,g ,(car (last vars-and-generator))))
       (loop 
	  do (if-generator ((,var ,@(butlast vars-and-generator)) ,g)
			   (progn
			     ,@body)
			   (return))))))

Macroexpansion:
(let ((#:g164 generator)) (loop do (if-generator ((g) #:g164) (progn (unless (funcall predicate g) (yield g))) (return))))
Create a Common Lisp macro for the following transformation. Before code:
(define-script-symbol-macro nil)

What needs to change: Macro call that should be transformed by DEFINE-SCRIPT-SYMBOL-MACRO

Macro definition:
(defmacro DEFINE-SCRIPT-SYMBOL-MACRO ...)

Macroexpansion:
(define-ps-symbol-macro nil)
Define a macro that eliminates this repetitive pattern:
(resolve
  nil)

Issue: Macro call that should be transformed by RESOLVE

Macro definition:
(defmacro RESOLVE ...)

Macroexpansion:
(locally
 (declare)
 (multiple-value-bind (#:assignment147 #:unified-p148)
     (type-unify 'nil 'nil (list))
   (assert #:unified-p148 nil 'simple-type-error :format-control
           "gtypes failed to unify to the actual types:~% ~a~%    against~% ~a"
           :format-arguments (list 'nil (list)))
   (let ()
     (declare (ignorable))
     nil)))
Create a Common Lisp macro for the following transformation. Before code:
(define-custom-var (:end-of-object *end-of-object-handler*) (constantly nil) "Designator for a function of no arguments (called at encountering a closing brace for an Object).")

What needs to change: Macro call that should be transformed by define-custom-var

Macro definition:
(defmacro define-custom-var ((key name) &rest other-args)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (progn (pushnew '(,name . ,key) *custom-vars* :test #'equal)
            (defvar ,name ,@other-args))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (pushnew (quote (*end-of-object-handler* . :end-of-object)) *custom-vars* :test (function equal)) (defvar *end-of-object-handler* (constantly nil) "Designator for a function of no arguments (called at encountering a closing brace for an Object).")))
You are a Common Lisp macro expert. Given this code pattern:
(resolve)

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

Macro definition:
(defmacro RESOLVE ...)

Macroexpansion:
(locally
 (declare)
 (multiple-value-bind (#:assignment145 #:unified-p146)
     (type-unify 'nil 'nil (list))
   (assert #:unified-p146 nil 'simple-type-error :format-control
           "gtypes failed to unify to the actual types:~% ~a~%    against~% ~a"
           :format-arguments (list 'nil (list)))
   (let ()
     (declare (ignorable)))))
You are a Common Lisp macro expert. Given this code pattern:
(do-for 'some-name)

Write a macro that addresses: Macro call that should be transformed by DO-FOR

Macro definition:
(defmacro DO-FOR ...)

Macroexpansion:
(block nil (lc ((block nil (tagbody (return (progn)))) quote some-name) progn))
Create a Common Lisp macro for the following transformation. Before code:
(with-html-string (:p (values "foo") (values "bar") (values "baz")))

What needs to change: Macro call that should be transformed by with-html

Macro definition:
(defmacro with-html (&body body &environment env)
  "Interpret BODY as HTML. Consult README.txt for the syntax."
  `(let ((*html* (ensure-html-stream *html*)))
     ,(if (and (null (cdr body)) (atom (car body)))
          (car body)
          `(progn ,@(parse-html body env)))))

Macroexpansion:
(with-output-to-string (*html*) (with-html (:p (values "foo") (values "bar") (values "baz"))))
Write a Common Lisp macro to handle this code pattern:
(ematch0 parsed1 ((list slot pattern) (let (effslot reader) (cond ((setf reader (find-reader slot type)) `((,reader ,it) ,pattern)) ((setf effslot (find-effective-slot slot type)) `((slot-value ,it ',(c2mop:slot-definition-name effslot)) ,pattern)) (t (error "Failed to deduce the way access the slot ~s" slot))))))

Problem: Macro call that should be transformed by ematch0

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

Macroexpansion:
(match0 parsed1 ((list slot pattern) (let (effslot reader) (cond ((setf reader (find-reader slot type)) (sb-int:quasiquote ((#S(sb-impl::comma :expr reader :kind 0) #S(sb-impl::comma :expr it :kind 0)) #S(sb-impl::comma :expr pattern :kind 0)))) ((setf effslot (find-effective-slot slot type)) (sb-int:quasiquote ((slot-value #S(sb-impl::comma :expr it :kind 0) (quote #S(sb-impl::comma :expr (sb-mop:slot-definition-name effslot) :kind 0))) #S(sb-impl::comma :expr pattern :kind 0)))) (t (error "Failed to deduce the way access the slot ~s" slot))))) (_ (error "level0 match error!")))
Generate a defmacro form that transforms code like this:
(when (not (eql (top-sign) 'skip-first-funcall)) (format stream ", "))

Pattern to recognize: 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 (not (eql (top-sign) (quote skip-first-funcall))) (format stream ", "))
Define a macro that eliminates this repetitive pattern:
(defsynonym :repeating :repeat)

Issue: Macro call that should be transformed by defsynonym

Macro definition:
(defmacro defsynonym (symbol synonym)
  "Set SYNONYM for a SYMBOL. "
  `(eval-always
     (setf (get ',symbol 'synonym) ',synonym)))

Macroexpansion:
(eval-always (setf (get (quote :repeating) (quote synonym)) (quote :repeat)))