j14i/cl-macros huggingface dataset:
Generate a defmacro form that transforms code like this:
(lambda-coro)

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

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

Macroexpansion:
(progn
 (defcoroutine #:name123
     (#:arg124)
   (macrolet ((yield (form)
                (let ((g!-it (gensym "IT")))
                  `(progn
                    (let ((,g!-it ,form))
                      (cl-coroutine:yield ,g!-it))
                    ,'#:arg124)))
              (last-yield-value ()
                '#:arg124))
     (coexit!)))
 (make-coroutine '#:name123))
You are a Common Lisp macro expert. Given this code pattern:
(deferror "23505" unique-violation integrity-violation)

Write a macro that addresses: 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 unique-violation (integrity-violation) nil) (setf (gethash "23505" *error-table*) (quote unique-violation)))
Create a Common Lisp macro for the following transformation. Before code:
(make-simple-appender-to-place nil)

What needs to change: Macro call that should be transformed by MAKE-SIMPLE-APPENDER-TO-PLACE

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

Macroexpansion:
(progn
 (setf nil (alexandria:ensure-list nil))
 (let ((#:tail131 (last nil)))
   (lambda (&rest values) (append-at-end nil #:tail131 values) nil)))
You are a Common Lisp macro expert. Given this code pattern:
(action (:after node-direct-application node) (when (eq name (node-rator-name node)) (incf count)) (values))

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-direct-application) (lambda (node) (declare (type node-direct-application node)) (when (eq name (node-rator-name node)) (incf count)) (values)))
You are a Common Lisp macro expert. Given this code pattern:
(as->* nil (progn))

Write a macro that addresses: Macro call that should be transformed by AS->*

Macro definition:
(defmacro AS->* ...)

Macroexpansion:
(as-> (progn) nil)
Generate a defmacro form that transforms code like this:
(enable-reader-syntax nil (progn))

Pattern to recognize: Macro call that should be transformed by ENABLE-READER-SYNTAX

Macro definition:
(defmacro ENABLE-READER-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (push *readtable* *previous-readtables*)
  (setq *readtable* (copy-readtable))
  (%enable-reader-syntax *readtable* nil (progn)))
Write a Common Lisp macro to handle this code pattern:
(f_n
  nil)

Problem: Macro call that should be transformed by F_N

Macro definition:
(defmacro F_N ...)

Macroexpansion:
(lambda (&rest _) nil)
Define a macro that eliminates this repetitive pattern:
(with-mocks () T)

Issue: 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 t) :recordp t)
You are a Common Lisp macro expert. Given this code pattern:
(assoc-cdr :last-name uinfo)

Write a macro that addresses: Macro call that should be transformed by assoc-cdr

Macro definition:
(defmacro assoc-cdr (key alist &optional (test '#'eql))
  `(cdr (assoc ,key ,alist :test ,test)))

Macroexpansion:
(cdr (assoc :last-name uinfo :test (function eql)))
Write a Common Lisp macro to handle this code pattern:
(false T)

Problem: Macro call that should be transformed by false

Macro definition:
(defmacro false (form &optional description &rest format-args)
  `(eval-in-context
    *context*
    (make-instance 'comparison-result
                   :expression '(false ,form)
                   :value-form ',form
                   :body (lambda () ,form)
                   :expected 'NIL
                   :comparison 'geq
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))

Macroexpansion:
(eval-in-context *context* (make-instance (quote comparison-result) :expression (quote (false t)) :value-form (quote t) :body (lambda nil t) :expected (quote nil) :comparison (quote geq)))
Create a Common Lisp macro for the following transformation. Before code:
(insert-char-class-tester (regex (schar *string* curr-pos)) (non-greedy-constant-length-closure (char-class-test)))

What needs to change: Macro call that should be transformed by insert-char-class-tester

Macro definition:
(defmacro insert-char-class-tester ((char-class chr-expr) &body body)
  "Utility macro to replace each occurence of '\(CHAR-CLASS-TEST)
within BODY with the correct test (corresponding to CHAR-CLASS)
against CHR-EXPR."
  (with-rebinding (char-class)
    (with-unique-names (test-function)
      (flet ((substitute-char-class-tester (new)
               (subst new '(char-class-test) body
                      :test #'equalp)))
        `(let ((,test-function (test-function ,char-class)))
           ,@(substitute-char-class-tester
              `(funcall ,test-function ,chr-expr)))))))

Macroexpansion:
(let ((#:char-class159 regex)) (let ((#:test-function160 (test-function #:char-class159))) (non-greedy-constant-length-closure (funcall #:test-function160 (schar *string* curr-pos)))))
Create a Common Lisp macro for the following transformation. Before code:
(when (first in-decl-item) (if (gethash identifier (first names)) (setf (first make-block) t) (progn (push identifier (first delta-names)) (setf (gethash identifier (first names)) t))))

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 (first in-decl-item) (if (gethash identifier (first names)) (setf (first make-block) t) (progn (push identifier (first delta-names)) (setf (gethash identifier (first names)) t))))
You are a Common Lisp macro expert. Given this code pattern:
(set-plist-val! nil :key nil)

Write a macro that addresses: Macro call that should be transformed by SET-PLIST-VAL!

Macro definition:
(defmacro set-plist-val! (new id place
                          &key (test '(default-test)) (key '(default-key)))
  `(setf ,place
    (set-plist-val ,new ,id ,place :test ,test :key ,key)))

Macroexpansion:
(setf nil (set-plist-val nil :key nil :test (default-test) :key (default-key)))
You are a Common Lisp macro expert. Given this code pattern:
(iterate:declare-variables)

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

Macro definition:
(defmacro iterate (&body body)
  "Jonathan Amsterdam's powerful iteration facility"
  `(iter .,body))

Macroexpansion:
(declare-variables)
Define a macro that eliminates this repetitive pattern:
(with-packages-unlocked nil
  nil)

Issue: Macro call that should be transformed by WITH-PACKAGES-UNLOCKED

Macro definition:
(defmacro WITH-PACKAGES-UNLOCKED ...)

Macroexpansion:
(let ((#:|packages121| (locked-packages 'nil)))
  (unlock-packages #:|packages121|)
  (unwind-protect nil (lock-packages #:|packages121|)))
Generate a defmacro form that transforms code like this:
(defhandler quote (quote object) `(list ',quote ',object))

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

Macro definition:
(defmacro defhandler (symbol lambda-list &body body)
  (let ((syms (force-list symbol)))
    (let ((func (intern (format nil "~A~A" 'hander- (first syms)))))
      `(progn
         (defun ,func ,lambda-list
           ,@body)
         (setf
          ,@(loop for sym in syms
               collect `(gethash ',sym *form-handler*)
               collect `',func))))))

Macroexpansion:
(progn (defun hander-quote (quote object) (sb-int:quasiquote (list (quote #S(sb-impl::comma :expr quote :kind 0)) (quote #S(sb-impl::comma :expr object :kind 0))))) (setf (gethash (quote quote) *form-handler*) (quote hander-quote)))
You are a Common Lisp macro expert. Given this code pattern:
(ematch0 more-patterns ((list _ pattern) (analyze-pattern pattern)) ((list* _ pattern more-patterns) (analyze-pattern pattern) (analyze-more-patterns more-patterns)))

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

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

Macroexpansion:
(match0 more-patterns ((list _ pattern) (analyze-pattern pattern)) ((list* _ pattern more-patterns) (analyze-pattern pattern) (analyze-more-patterns more-patterns)) (_ (error "level0 match error!")))
Create a Common Lisp macro for the following transformation. Before code:
(draw group (:circle :cx x :cy y :r (/ w 4)))

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

Macro definition:
(defmacro draw (scene (shape &rest params) &rest opts)
  (let ((element (gensym)))
    `(let ((,element (funcall #'make-svg-element ,shape (append (list ,@params) (list ,@opts)))))
       (add-element ,scene ,element)
       ,element)))

Macroexpansion:
(let ((#:g159 (funcall (function make-svg-element) :circle (append (list :cx x :cy y :r (/ w 4)) (list))))) (add-element group #:g159) #:g159)
Define a macro that eliminates this repetitive pattern:
(signal-syntax-error "There is no property named ~S." property-name)

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:
(signal-syntax-error* nil "There is no property named ~S." property-name)
Define a macro that eliminates this repetitive pattern:
(define-simple-object-lookup compiler-macro compiler-macro-function)

Issue: Macro call that should be transformed by define-simple-object-lookup

Macro definition:
(defmacro define-simple-object-lookup (class lookup-function &body body)
  `(defmethod object ((,class ,class))
     ,(if body
          `(let ((,(first lookup-function) ,class))
             ,@body)
          `(,lookup-function (designator ,class)))))

Macroexpansion:
(defmethod object ((compiler-macro compiler-macro)) (compiler-macro-function (designator compiler-macro)))
Create a Common Lisp macro for the following transformation. Before code:
(defsynonym collect :collect)

What needs to change: 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 collect) (quote synonym)) (quote :collect)))
Create a Common Lisp macro for the following transformation. Before code:
(*> +comma+ +skip-space-and-comments+)

What needs to change: 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 (#:*>-offset239) (multiple-value-bind (#:*>-res240 #:*>-next241) (funcall +comma+ #:*>-offset239) (if (ok? #:*>-res240) (funcall +skip-space-and-comments+ #:*>-next241) (fail #:*>-next241))))
Write a Common Lisp macro to handle this code pattern:
(do-for nil
  (progn))

Problem: Macro call that should be transformed by DO-FOR

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

Macroexpansion:
(block nil (lc ((block nil (tagbody (return (progn (progn)))))) progn))
You are a Common Lisp macro expert. Given this code pattern:
(define-condition partial-cant-be-found () ((partial-name :initarg :partial-name :type string :reader partial-name)) (:report (lambda (condition stream) (format stream "Unable to find dynamic partial \"~A\" in a context." (partial-name condition)))))

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

Macro definition:
(defmacro define (name template)
  "Define a named renderer of string TEMPLATE."
  `(setf (symbol-function ',name)
         (compile-template ,template)))

Macroexpansion:
(progn (sb-kernel::%define-condition (quote partial-cant-be-found) (quote (condition)) (sb-kernel::find-condition-layout (quote partial-cant-be-found) (quote (condition))) (list (sb-kernel::make-condition-slot :name (quote partial-name) :initargs (quote (:partial-name)) :readers (quote (partial-name)) :writers (quote nil) :initform-p (quote nil) :documentation (quote nil) :initform nil :initfunction nil :allocation (quote :instance))) (list) (quote (partial-name)) (quote nil) (sb-c:source-location)) (sb-kernel::%set-condition-report (quote partial-cant-be-found) (function (sb-int:named-lambda (sb-kernel::condition-report partial-cant-be-found) (condition stream) (declare (type condition condition) (type stream stream)) (funcall (function (lambda (condition stream) (format stream "Unable to find dynamic partial \"~A\" in a context." (partial-name condition)))) condition stream)))) (quote partial-cant-be-found))
Define a macro that eliminates this repetitive pattern:
(define-custom-var (:string-char *string-char-handler*) (constantly t) "Designator for a function of 1 character argument (String char).")

Issue: 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 (*string-char-handler* . :string-char)) *custom-vars* :test (function equal)) (defvar *string-char-handler* (constantly t) "Designator for a function of 1 character argument (String char).")))
You are a Common Lisp macro expert. Given this code pattern:
(flow-lambda-macro (flow-context) (with-flow-function-macro (body-fu lambda-list body) `(dispatch-atomically ,flow-context #',body-fu ,invariant ,@opts)))

Write a macro that addresses: Macro call that should be transformed by flow-lambda-macro

Macro definition:
(defmacro flow-lambda-macro ((flow-context) &body body)
  `(with-gensyms (,flow-context)
     `(%flow-lambda (,,flow-context)
        ,,@body)))

Macroexpansion:
(with-gensyms (flow-context) (sb-int:quasiquote (%flow-lambda (#S(sb-impl::comma :expr flow-context :kind 0)) #S(sb-impl::comma :expr (with-flow-function-macro (body-fu lambda-list body) (sb-int:quasiquote (dispatch-atomically #S(sb-impl::comma :expr flow-context :kind 0) (function #S(sb-impl::comma :expr body-fu :kind 0)) #S(sb-impl::comma :expr invariant :kind 0) #S(sb-impl::comma :expr opts :kind 2)))) :kind 0))))
Create a Common Lisp macro for the following transformation. Before code:
(enable-reader-syntax 'some-name)

What needs to change: Macro call that should be transformed by ENABLE-READER-SYNTAX

Macro definition:
(defmacro ENABLE-READER-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (push *readtable* *previous-readtables*)
  (setq *readtable* (copy-readtable))
  (%enable-reader-syntax *readtable* 'some-name))
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* ((#:var143 nil)
       (#:var144
        (if #:var143
            (progn #:var143)
            nil)))
  #:var144)
Define a macro that eliminates this repetitive pattern:
(defvar-compile-time *nondeterministic-context?* nil "This must be globally NIL.")

Issue: Macro call that should be transformed by defvar-compile-time

Macro definition:
(defmacro defvar-compile-time (name &optional initial-value documentation)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (defvar ,name ,initial-value ,documentation)))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (defvar *nondeterministic-context?* nil "This must be globally NIL."))
Write a Common Lisp macro to handle this code pattern:
(defpackage nil :key nil)

Problem: Macro call that should be transformed by DEFPACKAGE

Macro definition:
(defmacro DEFPACKAGE ...)

Macroexpansion:
(common-lisp:defpackage nil
  (:use :adhoc :closer-mop :cl)
  (:shadowing-import-from :closer-mop
                          #:defmethod
                          #:standard-generic-function
                          #:defgeneric
                          #:standard-method
                          #:standard-class)
  (:shadowing-import-from :adhoc #:defpackage #:variable #:the)
  :key
  ())
Define a macro that eliminates this repetitive pattern:
($ nil (progn))

Issue: Macro call that should be transformed by $

Macro definition:
(defmacro $ ...)

Macroexpansion:
(progn)
Write a Common Lisp macro to handle this code pattern:
(without-c-dependency (c-propagate c prior-value t))

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*) (c-propagate c prior-value t))
Generate a defmacro form that transforms code like this:
(collect-stream nil :key nil)

Pattern to recognize: Macro call that should be transformed by COLLECT-STREAM

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

Macroexpansion:
(common-lisp:let* ((#:generator-489 (generator :key)) #:items-484)
  (declare (type generator #:generator-489))
  (tagbody
   #:ll-490
    (setq #:items-484 (next-in #:generator-489 (go end)))
    (common-lisp:funcall nil #:items-484 nil)
    (go #:ll-490)
   end)
  nil)
Write a Common Lisp macro to handle this code pattern:
(defclass/a dbd-sqlite3-connection (dbi-connection) ())

Problem: 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-sqlite3-connection (dbi-connection) nil) (deftype <dbd-sqlite3-connection> nil (quote dbd-sqlite3-connection)) (setf (find-class (quote <dbd-sqlite3-connection>)) (find-class (quote dbd-sqlite3-connection))))
Create a Common Lisp macro for the following transformation. Before code:
(with-collectors nil
  :key
  nil)

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

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

Macroexpansion:
(progn :key nil)
You are a Common Lisp macro expert. Given this code pattern:
(with-yield (do-generators ((g (some-numbers)) (:list l data)) (yield (+ l g))))

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

Macro definition:
(defmacro with-yield (&body body)
  (let ((point (gensym))
        (current (gensym)))
    `(let (,point ,current)
       (with-call/cc
	 (labels ((yield (&rest values)
		    (setf ,current values)
		    (let/cc k
		      (setf ,point k))))
	   ,@body
	   (setf ,point nil)))
       (gen-lambda ()
	 (cond ((null ,point)
		'generator-stop)
	       (t
		(let ((current ,current))
		  (funcall ,point nil)
		  ;values-handler: see gen-lambda
		  (apply #'values (funcall values-handler current)))))))))

Macroexpansion:
(let (#:g145 #:g146) (with-call/cc (labels ((yield (&rest values) (setf #:g146 values) (let/cc k (setf #:g145 k)))) (do-generators ((g (some-numbers)) (:list l data)) (yield (+ l g))) (setf #:g145 nil))) (gen-lambda nil (cond ((null #:g145) (quote generator-stop)) (t (let ((current #:g146)) (funcall #:g145 nil) (apply (function values) (funcall values-handler current)))))))
Generate a defmacro form that transforms code like this:
(%proper-list-p object)

Pattern to recognize: Macro call that should be transformed by %proper-list-p

Macro definition:
(defmacro %proper-list-p (var &optional (element-type '*))
  `(loop
     (typecase ,var
       (null (return t))
       (cons (if (or ,(eq element-type '*)
                     (typep (car ,var) ,element-type))
                 (setq ,var (cdr ,var))
                 (return)))
       (t    (return)))))

Macroexpansion:
(loop (typecase object (null (return t)) (cons (if (or t (typep (car object) *)) (setq object (cdr object)) (return))) (t (return))))
Define a macro that eliminates this repetitive pattern:
(defun/1 putc (c fd) (fputc c fd))

Issue: Macro call that should be transformed by defun/1

Macro definition:
(defmacro defun/1 (name arglist &body body)
  "Lisp-1 defun; makes function pointers work."
  `(progn
     (defun ,name ,arglist
       (declare (optimize (speed 0) (debug 3)
                          ;; FIXME: Why do minor warnings result in load errors?
                          #+sbcl (sb-ext:inhibit-warnings 3)))
        
       ,@body)
     (defparameter ,name (vacietis.c:mkptr& (symbol-function ',name)))))

Macroexpansion:
(progn (defun putc (c fd) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (fputc c fd)) (defparameter putc (vacietis.c:mkptr& (symbol-function (quote putc)))))
You are a Common Lisp macro expert. Given this code pattern:
(assoc-cdr "code" parameters #'equal)

Write a macro that addresses: Macro call that should be transformed by assoc-cdr

Macro definition:
(defmacro assoc-cdr (key alist &optional (test '#'eql))
  `(cdr (assoc ,key ,alist :test ,test)))

Macroexpansion:
(cdr (assoc "code" parameters :test (function equal)))