j14i/cl-macros huggingface dataset:
Generate a defmacro form that transforms code like this:
(*> +array-open+ +skip-space-and-comments+)

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

Macro definition:
(defmacro *> (parser &rest parsers)
  "Combination of parsers yielding the result of the rightmost one."
  (let ((offset (gensym "*>-OFFSET")))
    `(lambda (,offset)
       ,(reduce (lambda (i p)
                  (let ((res  (gensym "*>-RES"))
                        (next (gensym "*>-NEXT")))
                    `(multiple-value-bind (,res ,next) ,i
                       (if (ok? ,res)
                           (funcall ,p ,next)
                           (fail ,next)))))
                parsers
                :initial-value `(funcall ,parser ,offset)))))

Macroexpansion:
(lambda (#:*>-offset236) (multiple-value-bind (#:*>-res237 #:*>-next238) (funcall +array-open+ #:*>-offset236) (if (ok? #:*>-res237) (funcall +skip-space-and-comments+ #:*>-next238) (fail #:*>-next238))))
Define a macro that eliminates this repetitive pattern:
(special-symbol-progv nil
    nil)

Issue: Macro call that should be transformed by SPECIAL-SYMBOL-PROGV

Macro definition:
(defmacro SPECIAL-SYMBOL-PROGV ...)

Macroexpansion:
(let (#:symbol-list176)
  (tagbody
   #:retry177
    (setq #:symbol-list176 nil)
    (unless (every #'special-symbol-p #:symbol-list176)
      (cerror "Retry to rebind the place(s)."
              "Attempt at rebinding one or more non-special places: ~S" 'nil)
      (go #:retry177)))
  (dynamic-progv #:symbol-list176
      nil))
Create a Common Lisp macro for the following transformation. Before code:
(with-yield
  'some-name)

What needs to change: Macro call that should be transformed by WITH-YIELD

Macro definition:
(defmacro WITH-YIELD ...)

Macroexpansion:
(isolate-cont
  (enable-yield
    nil
    'some-name))
Create a Common Lisp macro for the following transformation. Before code:
(labels* nil
  (progn))

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

Macro definition:
(defmacro LABELS* ...)

Macroexpansion:
(labels ()
  (progn))
Create a Common Lisp macro for the following transformation. Before code:
(when (typep (node-slot name) 'identifier) (format stream "~~"))

What needs to change: 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 (typep (node-slot name) (quote identifier)) (format stream "~~"))
Create a Common Lisp macro for the following transformation. Before code:
(var nil (progn))

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

Macro definition:
(defmacro VAR ...)

Macroexpansion:
(defparameter nil (progn))
You are a Common Lisp macro expert. Given this code pattern:
(defparam nil nil)

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

Macro definition:
(defmacro DEFPARAM ...)

Macroexpansion:
(setf (gethash #A((3) base-char . "NIL") cl-rules.core::*parameters*) nil)
Generate a defmacro form that transforms code like this:
(rte-case 'some-name)

Pattern to recognize: Macro call that should be transformed by RTE-CASE

Macro definition:
(defmacro RTE-CASE ...)

Macroexpansion:
(let ((#:rte170 'some-name))
  (typecase #:rte170
    ((not sequence) nil)
    (t
     (funcall
      (lambda (#:rte170)
        (declare (optimize (speed 3) (debug 0) (safety 0)))
        (block check
          (typecase #:rte170
            (list nil)
            (simple-vector
             (let ((i 0) (len (length #:rte170)))
               (declare (type (and unsigned-byte fixnum) i len)
                        (ignorable len))
               nil))
            (vector
             (let ((i 0) (len (length #:rte170)))
               (declare (type (and fixnum unsigned-byte) i len)
                        (ignorable len))
               nil))
            (sequence
             (let ((i 0) (len (sb-sequence:length #:rte170)))
               (declare (type (and fixnum unsigned-byte) i len)
                        (ignorable len))
               nil))
            (t nil))))
      #:rte170))))
Write a Common Lisp macro to handle this code pattern:
(with-html-string (:p (:button "Log in") (:a :href "#" "Forgot?")))

Problem: 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 (:button "Log in") (:a :href "#" "Forgot?"))))
You are a Common Lisp macro expert. Given this code pattern:
(path (move-to 100 400) (line-to-r 50 -25) (arc-to-r 25 25 -30 0 1 50 -25) (line-to-r 50 -25) (arc-to-r 25 50 -30 0 1 50 -25) (line-to-r 50 -25) (arc-to-r 25 75 -30 0 1 50 -25) (line-to-r 50 -25) (arc-to-r 25 100 -30 0 1 50 -25) (line-to-r 50 -25) (vertical-to-r 50))

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

Macro definition:
(defmacro path (&body cmds)
  (let ((path (gensym "path")))
    `(let ((,path (make-path)))
       (with-path ,path
         ,@cmds)
       ,path)))

Macroexpansion:
(let ((#:|path141| (make-path))) (with-path #:|path141| (move-to 100 400) (line-to-r 50 -25) (arc-to-r 25 25 -30 0 1 50 -25) (line-to-r 50 -25) (arc-to-r 25 50 -30 0 1 50 -25) (line-to-r 50 -25) (arc-to-r 25 75 -30 0 1 50 -25) (line-to-r 50 -25) (arc-to-r 25 100 -30 0 1 50 -25) (line-to-r 50 -25) (vertical-to-r 50)) #:|path141|)
Write a Common Lisp macro to handle this code pattern:
($ 'some-name)

Problem: Macro call that should be transformed by $

Macro definition:
(defmacro $ ...)

Macroexpansion:
'some-name
Write a Common Lisp macro to handle this code pattern:
(aand (+ 1 1) (+ 1 it))

Problem: Macro call that should be transformed by aand

Macro definition:
(defmacro aand (first &rest rest)
  "Like AND, except binds the first argument to IT (via LET) for the
scope of the rest of the arguments."
  `(anaphoric and ,first ,@rest))

Macroexpansion:
(anaphoric and (+ 1 1) (+ 1 it))
Write a Common Lisp macro to handle this code pattern:
(defiter nil
    :key
  nil)

Problem: Macro call that should be transformed by DEFITER

Macro definition:
(defmacro DEFITER ...)

Macroexpansion:
(defun nil :key
  (make-instance 'iterator :coro
                 (lambda-coro
                   nil)))
Generate a defmacro form that transforms code like this:
(when-let* ((x 2) (y x)) (+ x y))

Pattern to recognize: Macro call that should be transformed by when-let*

Macro definition:
(defmacro when-let* (bindings &body body)
  "Creates new variable bindings, and conditionally executes BODY.

BINDINGS must be either single binding of the form:

 (variable initial-form)

or a list of bindings of the form:

 ((variable-1 initial-form-1)
  (variable-2 initial-form-2)
  ...
  (variable-n initial-form-n))

Each INITIAL-FORM is executed in turn, and the variable bound to the
corresponding value. INITIAL-FORM expressions can refer to variables
previously bound by the WHEN-LET*.

Execution of WHEN-LET* stops immediately if any INITIAL-FORM evaluates to NIL.
If all INITIAL-FORMs evaluate to true, then BODY is executed as an implicit
PROGN."
  (let ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
                          (list bindings)
                          bindings)))
    (labels ((bind (bindings body)
               (if bindings
                   `(let (,(car bindings))
                      (when ,(caar bindings)
                        ,(bind (cdr bindings) body)))
                   `(progn ,@body))))
      (bind binding-list body))))

Macroexpansion:
(let ((x 2)) (when x (let ((y x)) (when y (progn (+ x y))))))
Create a Common Lisp macro for the following transformation. Before code:
(do+ (for (k v) (hash-entries-of ht)) (collect (cons k v)))

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

Macro definition:
(defmacro do+ (&body body)
  "High-level, extensible iteration construct. Refer to the manual for syntax and semantics."
  `(do+/internal nil ,@body))

Macroexpansion:
(do+/internal nil (for (k v) (hash-entries-of ht)) (collect (cons k v)))
Define a macro that eliminates this repetitive pattern:
(ct-let* nil
  :key
  nil)

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

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

Macroexpansion:
(cond (*within-captured-dynenv* (progn :key nil))
      (t
       (error
        "No macrodynamic environment has been captured to establish CT-LET* bindings.")))
Define a macro that eliminates this repetitive pattern:
(def-neo4j-fun get-relationship-properties (relationship-id) :get (:uri-spec (format nil "relationship/~A/properties" relationship-id)) (:status-handlers (200 (decode-neo4j-json-output body)) (204 nil) (404 (error 'relationship-not-found-error :uri uri))))

Issue: Macro call that should be transformed by def-neo4j-fun

Macro definition:
(defmacro def-neo4j-fun (name lambda-list method &rest args)
  `(progn
     (defun ,name (&key ,@lambda-list)
       (let ((uri ,(cadr (assoc :uri-spec args)))
             (json (encode-neo4j-json-payload ,@(aif (assoc :encode args)
                                                     (cdr it)
                                                     (list '() :string)))))
         (make-neo4j-request ,method uri json
                             (list ,@(mapcar (lambda (handler)
                                               `(list ,(car handler) (lambda (body uri json)
                                                                  ,(cadr handler))))
                                             (cdr (assoc :status-handlers args)))))))))

Macroexpansion:
(progn (defun get-relationship-properties (&key relationship-id) (let ((uri (format nil "relationship/~A/properties" relationship-id)) (json (encode-neo4j-json-payload nil :string))) (make-neo4j-request :get uri json (list (list 200 (lambda (body uri json) (decode-neo4j-json-output body))) (list 204 (lambda (body uri json) nil)) (list 404 (lambda (body uri json) (error (quote relationship-not-found-error) :uri uri))))))))
Create a Common Lisp macro for the following transformation. Before code:
(when (eql counter 0) (return))

What needs to change: 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 counter 0) (return))
Create a Common Lisp macro for the following transformation. Before code:
(defgenerator ifilter-false (predicate generator) "Emits only those items in generator that are false by predicate. The generator equivalent of remove-if" (do-generator (g generator) (unless (funcall predicate g) (yield g))))

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

Macro definition:
(defmacro defgenerator (name arguments &body body)
  (multiple-value-bind (remaining-forms declarations doc-string)
      (alexandria:parse-body body :documentation t)
    `(defun ,name ,arguments
       ,doc-string
       ,@declarations
       (with-yield
	 ,@remaining-forms))))

Macroexpansion:
(defun ifilter-false (predicate generator) "Emits only those items in generator that are false by predicate. The generator equivalent of remove-if" (with-yield (do-generator (g generator) (unless (funcall predicate g) (yield g)))))
Generate a defmacro form that transforms code like this:
(def-neo4j-fun remove-from-index ((type :node) name key value object-id) :delete (:uri-spec (format nil "index/~A/~A/~@[~A/~]~@[~A/~]~A" (string-downcase (symbol-name type)) name key (urlencode value) object-id)) (:status-handlers (204 (values t body)) (404 (error 'index-entry-not-found-error :uri uri))))

Pattern to recognize: Macro call that should be transformed by def-neo4j-fun

Macro definition:
(defmacro def-neo4j-fun (name lambda-list method &rest args)
  `(progn
     (defun ,name (&key ,@lambda-list)
       (let ((uri ,(cadr (assoc :uri-spec args)))
             (json (encode-neo4j-json-payload ,@(aif (assoc :encode args)
                                                     (cdr it)
                                                     (list '() :string)))))
         (make-neo4j-request ,method uri json
                             (list ,@(mapcar (lambda (handler)
                                               `(list ,(car handler) (lambda (body uri json)
                                                                  ,(cadr handler))))
                                             (cdr (assoc :status-handlers args)))))))))

Macroexpansion:
(progn (defun remove-from-index (&key (type :node) name key value object-id) (let ((uri (format nil "index/~A/~A/~@[~A/~]~@[~A/~]~A" (string-downcase (symbol-name type)) name key (urlencode value) object-id)) (json (encode-neo4j-json-payload nil :string))) (make-neo4j-request :delete uri json (list (list 204 (lambda (body uri json) (values t body))) (list 404 (lambda (body uri json) (error (quote index-entry-not-found-error) :uri uri))))))))
Define a macro that eliminates this repetitive pattern:
(do-sequences! ((item1 seq1 :start start1 :end end1) (item2 seq2 :start start2 :end end2)) (setf item1 item2))

Issue: Macro call that should be transformed by do-sequences

Macro definition:
(defmacro do-sequences (name/seqs &body forms &environment env)
  "Iterate over the elements of one or more sequences.

   Iteration is performed using the iterator interface, and over
   multiple sequences simultaneously.

   The macro arguments can be in one of the following two forms:

    1. (NAME (&REST SEQS) &BODY BODY)

    2. ((&REST SEQS) &BODY BODY)

   NAME is a symbol serving as the name of the BLOCK from which the
   forms in BODY can return, using (RETURN-FROM NAME ...). If not
   given defaults to NIL.

   Each element of SEQS is a list of the form (VAR SEQUENCE . ARGS),
   where VAR is the variable to which the element of the sequence,
   SEQUENCE, is bound, at each iteration, and ARGS are arguments
   passed to the ITERATOR function, after the sequence.

   BODY is a list of forms evaluated at each iteration. RETURN-FROM to
   the block named NAME may be used to terminate the iteration early
   and return a value from the DO-SEQUENCES form. NIL is returned if
   there is no explicit RETURN."

  (let-if ((name name/seqs)
           (seqs (first forms) name/seqs)
           (forms (rest forms) forms))
      (symbolp name/seqs)

    (let ((safety (cadr (assoc 'safety (declaration-information 'optimize env)))))
      `(,(if (> safety 2)
             'do-sequences-safe%
             'do-sequences-fast%)

         ,name
         ,seqs
         ,@forms))))

Macroexpansion:
(do-sequences!-fast% nil ((item1 seq1 :start start1 :end end1) (item2 seq2 :start start2 :end end2)) (setf item1 item2))
You are a Common Lisp macro expert. Given this code pattern:
(orf (formatted-message-text self) (format-message self))

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

Macro definition:
(defmacro orf (location form &environment env)
  (multiple-value-bind (vars values new setter getter)
      (get-setf-expansion location env)
    (when (cdr new)
      (error "Can't work with setf-expansion for ~s - ~d values from setter ~s"
             location (length new) new))
    (let ((current (car new)))
      `(let* (,@(mapcar 'list vars values)
              (,current ,getter))
         (or ,current
             (progn (setf ,current ,form)
               ,setter))))))

Macroexpansion:
(let* ((#:self132 self) (#:new131 (formatted-message-text #:self132))) (or #:new131 (progn (setf #:new131 (format-message self)) (funcall (function (setf formatted-message-text)) #:new131 #:self132))))
Generate a defmacro form that transforms code like this:
(with-special-initargs* 'some-name)

Pattern to recognize: Macro call that should be transformed by WITH-SPECIAL-INITARGS*

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

Macroexpansion:
(with-special-initargs (quote)
  (with-special-initargs* (some-name)))
Define a macro that eliminates this repetitive pattern:
(match nil nil)

Issue: Macro call that should be transformed by MATCH

Macro definition:
(defmacro MATCH ...)

Macroexpansion:
(block #:match125 (when (and (not nil)) (return-from #:match125 nil)))
You are a Common Lisp macro expert. Given this code pattern:
(define-custom-var (:end-of-array *end-of-array-handler*) (constantly nil) "Designator for a function of no arguments (called at encountering a closing bracket for an Array).")

Write a macro that addresses: 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-array-handler* . :end-of-array)) *custom-vars* :test (function equal)) (defvar *end-of-array-handler* (constantly nil) "Designator for a function of no arguments (called at encountering a closing bracket for an Array).")))
Generate a defmacro form that transforms code like this:
(when-let* ((x t) (y (consp x)) (z (error "OOPS"))) t)

Pattern to recognize: Macro call that should be transformed by when-let

Macro definition:
(defmacro when-let (bindings &body forms)
    "Creates new variable bindings, and conditionally executes FORMS.

BINDINGS must be either single binding of the form:

 (variable initial-form)

or a list of bindings of the form:

 ((variable-1 initial-form-1)
  (variable-2 initial-form-2)
  ...
  (variable-n initial-form-n))

All initial-forms are executed sequentially in the specified order. Then all
the variables are bound to the corresponding values.

If all variables were bound to true values, then FORMS are executed as an
implicit PROGN."
  (let* ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
                           (list bindings)
                           bindings))
         (variables (mapcar #'car binding-list)))
    `(let ,binding-list
       (when (and ,@variables)
         ,@forms))))

Macroexpansion:
(let ((x t)) (when x (let ((y (consp x))) (when y (let ((z (error "OOPS"))) (when z (progn t)))))))
Define a macro that eliminates this repetitive pattern:
(c?-with-stored (v :bar store 'nothing) (bwhen (val (value v)) val))

Issue: Macro call that should be transformed by c?-with-stored

Macro definition:
(defmacro c?-with-stored ((var key store &optional default) &body body)
  `(c? (bwhen-c-stored (,var ,key ,store ,default)
	 ,@body)))

Macroexpansion:
(c? (bwhen-c-stored (v :bar store (quote nothing)) (bwhen (val (value v)) val)))
You are a Common Lisp macro expert. Given this code pattern:
(c? (c-assert (listp (kid-values self))) (mapsort (^sort-map) (the-kids (mapcar (lambda (kid-value) (trc "making kid" kid-value) (or (find kid-value .cache :key (kv-key self) :test (kv-key-test self)) (trc nil "family-values forced to make new kid" self .cache kid-value) (funcall (kid-factory self) self kid-value))) (^kid-values)))))

Write a macro that addresses: 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 ((c-assert (listp (kid-values self))) (mapsort (^sort-map) (the-kids (mapcar (lambda (kid-value) (trc "making kid" kid-value) (or (find kid-value .cache :key (kv-key self) :test (kv-key-test self)) (trc nil "family-values forced to make new kid" self .cache kid-value) (funcall (kid-factory self) self kid-value))) (^kid-values)))))) :value-state :unevaluated :rule (c-lambda (c-assert (listp (kid-values self))) (mapsort (^sort-map) (the-kids (mapcar (lambda (kid-value) (trc "making kid" kid-value) (or (find kid-value .cache :key (kv-key self) :test (kv-key-test self)) (trc nil "family-values forced to make new kid" self .cache kid-value) (funcall (kid-factory self) self kid-value))) (^kid-values))))))
Write a Common Lisp macro to handle this code pattern:
(define-syntax common-lisp:nil common-lisp:nil)

Problem: Macro call that should be transformed by DEFINE-SYNTAX

Macro definition:
(defmacro DEFINE-SYNTAX ...)

Macroexpansion:
(common-lisp:defmacro common-lisp:nil
                      (
                       common-lisp:&rest
                       |https://github.com/g000001/mbe#internals|::__syntax-rules-arg__)
  (common-lisp:let ((|https://github.com/g000001/mbe#internals|::__syntax-rules-arg__
                     (common-lisp:cons 'common-lisp:nil
                                       |https://github.com/g000001/mbe#internals|::__syntax-rules-arg__))
                    (|https://github.com/g000001/mbe#internals|::__syntax-rules-keywords__
                     '(common-lisp:nil)))
    (common-lisp:cond
     (common-lisp:t
      (common-lisp:error "~a: no matching clause" 'common-lisp:nil)))))
Define a macro that eliminates this repetitive pattern:
(setf)

Issue: Macro call that should be transformed by SETF

Macro definition:
(defmacro SETF ...)

Macroexpansion:
nil
You are a Common Lisp macro expert. Given this code pattern:
(any-of nil
  nil)

Write a macro that addresses: Macro call that should be transformed by ANY-OF

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

Macroexpansion:
(lc (nil nil) thereis)
Generate a defmacro form that transforms code like this:
(isnt "1" 1)

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

Macro definition:
(defmacro is (got expected &rest args)
  (with-gensyms (duration result new-args desc)
    (once-only (expected)
      `(let* ((,new-args (list ,@args))
              (,desc (parse-description-and-test ,new-args)))
         (with-catching-errors (:description ,desc :expected ,expected)
           (with-duration ((,duration ,result) ,got)
             (test ,result ,expected ,new-args
                   :duration ,duration)))))))

Macroexpansion:
(let ((#:expected161 1)) (let* ((#:new-args159 (list)) (#:desc160 (parse-description-and-test #:new-args159))) (with-catching-errors (:description #:desc160 :expected #:expected161) (with-duration ((#:duration157 #:result158) "1") (test #:result158 #:expected161 #:new-args159 :notp t :duration #:duration157)))))
You are a Common Lisp macro expert. Given this code pattern:
(with-mocks () (register-mock 'foo) (is (null (multiple-value-list (foo)))))

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

Macro definition:
(defmacro with-mocks ((&key (recordp T)) &body body)
  "Execute BODY in a new mocking context.  Invocations will be recorded
if RECORDP is set (default true)."
  `(call-with-mocks
    (lambda () ,@body)
    :recordp ,recordp))

Macroexpansion:
(call-with-mocks (lambda nil (register-mock (quote foo)) (is (null (multiple-value-list (foo))))) :recordp t)