j14i/cl-macros huggingface dataset:
Generate a defmacro form that transforms code like this:
(continue-whopper 'some-name)

Pattern to recognize: 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 'some-name))
Define a macro that eliminates this repetitive pattern:
(set-bop nil nil)

Issue: Macro call that should be transformed by SET-BOP

Macro definition:
(defmacro SET-BOP ...)

Macroexpansion:
(eval-when (:load-toplevel :compile-toplevel :execute)
  (progn
   (save-binfix)
   (mapc
    (lambda (ops)
      (mapc
       (lambda (op1)
         (when (eq (car op1) 'nil)
           (setf (cadr op1) 'nil)
           (unless t (setf (cddr op1) 'nil))))
       ops))
    *binfix*)
   (assign-properties)))
Write a Common Lisp macro to handle this code pattern:
(mvlet* (x) x)

Problem: Macro call that should be transformed by mvlet*

Macro definition:
(defmacro mvlet* ((&rest bindings) &body body &environment env)
  "Expand a series of nested `multiple-value-bind' forms.

`mvlet*' is similar in intent to Scheme’s `let-values', but with a
different and less parenthesis-intensive syntax. Each binding is a
list of

    (var var*... expr)

A simple example should suffice to show both the implementation and
the motivation:

    (defun uptime (seconds)
      (mvlet* ((minutes seconds (truncate seconds 60))
               (hours minutes (truncate minutes 60))
               (days hours (truncate hours 24)))
        (declare ((integer 0 *) days hours minutes seconds))
        (fmt \"~d day~:p, ~d hour~:p, ~d minute~:p, ~d second~:p\"
             days hours minutes seconds)))

Note that declarations work just like `let*'."
  (cond ((null bindings)
         `(locally ,@body))
        ((every #'simple-binding-p bindings)
         `(let* ,bindings ,@body))
        (t (multiple-value-bind (body decls)
               (parse-body body)
             (let* ((bindings (canonicalize-bindings bindings))
                    (mvbinds (member-if-not #'simple-binding-p bindings))
                    (simple-binds (ldiff bindings mvbinds)))
               (if simple-binds
                   (multiple-value-bind (local other)
                       (partition-declarations (mapcar #'car simple-binds) decls env)
                     `(let* ,simple-binds
                        ,@local
                        (mvlet* ,mvbinds
                          ,@other
                          ,@body)))
                   (let* ((vars (butlast (car bindings)))
                          (expr (lastcar (car bindings))))
                     (multiple-value-bind (local other)
                         (partition-declarations vars decls env)
                       `(multiple-value-bind ,vars
                            ,expr
                          ,@local
                          (mvlet* ,(cdr bindings)
                            ,@other
                            ,@body))))))))))

Macroexpansion:
(let* (x) x)
Create a Common Lisp macro for the following transformation. Before code:
(when (not (node-slot body)) (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 (not (node-slot body)) (format stream ";"))
Create a Common Lisp macro for the following transformation. Before code:
(ematch0 clause ((list* patterns body) (list* (expand-multipatterns patterns) body)))

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

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

Macroexpansion:
(match0 clause ((list* patterns body) (list* (expand-multipatterns patterns) body)) (_ (error "level0 match error!")))
You are a Common Lisp macro expert. Given this code pattern:
(make-simple-collector-to-place nil)

Write a macro that addresses: Macro call that should be transformed by MAKE-SIMPLE-COLLECTOR-TO-PLACE

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

Macroexpansion:
(progn
 (setf nil (alexandria:ensure-list nil))
 (let* ((#:tail123 (last nil)))
   (lambda (&rest values) (collect-at-end nil #:tail123 values) nil)))
Create a Common Lisp macro for the following transformation. Before code:
(with-prepared-query query (*connection* sql :use-prepare-cached *use-prepare-cached*) (setf query (execute-with-retry query binds)) (query-row-count query))

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

Macro definition:
(defmacro with-prepared-query (query (conn sql &key use-prepare-cached) &body body)
  `(call-with-prepared-query ,conn ,sql (lambda (,query) ,@body) :use-prepare-cached ,use-prepare-cached))

Macroexpansion:
(call-with-prepared-query *connection* sql (lambda (query) (setf query (execute-with-retry query binds)) (query-row-count query)) :use-prepare-cached *use-prepare-cached*)
Generate a defmacro form that transforms code like this:
(define-script-symbol-macro nil
  nil)

Pattern to recognize: Macro call that should be transformed by DEFINE-SCRIPT-SYMBOL-MACRO

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

Macroexpansion:
(define-ps-symbol-macro nil nil)
Write a Common Lisp macro to handle this code pattern:
(is-print (princ "ABCDEFGH") "ABCDEFGHIJKLMNO")

Problem: Macro call that should be transformed by is-print

Macro definition:
(defmacro is-print (got expected &optional desc)
  (with-gensyms (output duration duration-inner)
    (once-only (expected desc)
      `(with-catching-errors (:description ,desc :expected ,expected)
         (let* (,duration
                (,output (with-output-to-string (*standard-output*)
                           (with-duration ((,duration-inner ,output) ,got)
                             (declare (ignore ,output))
                             (setq ,duration ,duration-inner)))))
           (test ,output ,expected ,desc
                 :duration ,duration
                 :got-form ',got
                 :test-fn #'string=
                 :report-expected-label "output"))))))

Macroexpansion:
(let ((#:expected203 "ABCDEFGHIJKLMNO") (#:desc204 nil)) (with-catching-errors (:description #:desc204 :expected #:expected203) (let* (#:duration201 (#:output200 (with-output-to-string (*standard-output*) (with-duration ((#:duration-inner202 #:output200) (princ "ABCDEFGH")) (declare (ignore #:output200)) (setq #:duration201 #:duration-inner202))))) (test #:output200 #:expected203 #:desc204 :duration #:duration201 :got-form (quote (princ "ABCDEFGH")) :test-fn (function string=) :report-expected-label "output"))))
Define a macro that eliminates this repetitive pattern:
(define-hook-type string->string (function (string) string) "Hook that takes a string and produces a new one.")

Issue: Macro call that should be transformed by define-hook-type

Macro definition:
(defmacro define-hook-type (name type &optional documentation)
  "Define hook class.
Type must be something like:

  (function (string) (values integer t))

The `handler-type' of the defined hook class has `:class' allocation
type, so that all hooks of such class have the same `handler-type'."
  (let* ((name (string name))
         (hook-class-name (intern (serapeum:concat "HOOK-" name))))
    `(defclass ,hook-class-name (hook)
       ((handler-type :initform ',type :allocation :class))
       (:metaclass closer-mop:funcallable-standard-class)
       ,@(when documentation
           `((:documentation ,documentation))))))

Macroexpansion:
(defclass hook-string->string (hook) ((handler-type :initform (quote (function (string) string)) :allocation :class)) (:metaclass sb-mop:funcallable-standard-class) (:documentation "Hook that takes a string and produces a new one."))
You are a Common Lisp macro expert. Given this code pattern:
(-<> -<>> some-<> some-<>>)

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

Macro definition:
(defmacro -<> (init &body exps) (diamond-wand init exps))

Macroexpansion:
(block #:g122 (block #:g121 -<>>))
Generate a defmacro form that transforms code like this:
(defclass/std example () ((slot1 slot2 slot3)))

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

Macro definition:
(defmacro defclass/std (name direct-superclasses direct-slots &rest options
                        &environment env)
  "Shortcut macro to the DEFCLASS macro.

  (defclass/std example ()
    ((slot1 slot2 slot3)))

  expands to:

  (DEFCLASS EXAMPLE ()
    ((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL)
    (SLOT2 :ACCESSOR SLOT2 :INITARG :SLOT2 :INITFORM NIL)
    (SLOT3 :ACCESSOR SLOT3 :INITARG :SLOT3 :INITFORM NIL)))

  Each slot definition accepts options:

    :std 1 => changes the :initform to 1. It can be :unbound.
    :with or :with-prefix => creates accessors with the class name as prefix.

  See the README for more.

  See also `class/std' and `print-object/std'.
  "
  `(defclass ,name ,direct-superclasses
     ,(process-slots env direct-slots name)
     ,@options))

Macroexpansion:
(defclass example nil ((slot1 :accessor slot1 :initarg :slot1 :initform nil) (slot2 :accessor slot2 :initarg :slot2 :initform nil) (slot3 :accessor slot3 :initarg :slot3 :initform nil)))
Create a Common Lisp macro for the following transformation. Before code:
(-> :g () 2)

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

Macro definition:
(defmacro -> (invariant &body args)
  "See flow:atomically"
  `(atomically ,invariant ,@args))

Macroexpansion:
(atomically :g nil 2)
Define a macro that eliminates this repetitive pattern:
(with-log-error-handling () (with-wcs-math-error-handling (ret (log1+ x)) (check-wcs-math-result)))

Issue: Macro call that should be transformed by with-log-error-handling

Macro definition:
(defmacro with-log-error-handling (() &body body)
  `(handler-case
      (progn ,@body)
    #+allegro
    ;; TODO: rewrite other `simple-error' handler to use arithmetic-error.
    (arithmetic-error (e)
      (let ((operands (arithmetic-error-operands e)))
        (cond ((zerop (first operands))
               (wcs-raise-fe-exception FE_DIVBYZERO :errno ERANGE)
               (- HUGE_VAL))
              (t
               (error e)))))))

Macroexpansion:
(handler-case (progn (with-wcs-math-error-handling (ret (log1+ x)) (check-wcs-math-result))))
Write a Common Lisp macro to handle this code pattern:
(signal-reader-error "Could not find character with name '~A'" name)

Problem: Macro call that should be transformed by signal-reader-error

Macro definition:
(defmacro signal-reader-error (format-control &rest format-arguments)
  "Like ERROR but signals a SIMPLE-READER-ERROR for the stream
*STREAM*."
  `(error 'simple-reader-error
          :stream *stream*
          :format-control ,format-control
          :format-arguments (list ,@format-arguments)))

Macroexpansion:
(error (quote simple-reader-error) :stream *stream* :format-control "Could not find character with name '~A'" :format-arguments (list name))
Define a macro that eliminates this repetitive pattern:
(defclass/std unknown () ((slot :wi :unknown keywords :and values)))

Issue: Macro call that should be transformed by defclass/std

Macro definition:
(defmacro defclass/std (name direct-superclasses direct-slots &rest options
                        &environment env)
  "Shortcut macro to the DEFCLASS macro.

  (defclass/std example ()
    ((slot1 slot2 slot3)))

  expands to:

  (DEFCLASS EXAMPLE ()
    ((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL)
    (SLOT2 :ACCESSOR SLOT2 :INITARG :SLOT2 :INITFORM NIL)
    (SLOT3 :ACCESSOR SLOT3 :INITARG :SLOT3 :INITFORM NIL)))

  Each slot definition accepts options:

    :std 1 => changes the :initform to 1. It can be :unbound.
    :with or :with-prefix => creates accessors with the class name as prefix.

  See the README for more.

  See also `class/std' and `print-object/std'.
  "
  `(defclass ,name ,direct-superclasses
     ,(process-slots env direct-slots name)
     ,@options))

Macroexpansion:
(defclass unknown nil ((slot :writer slot :initarg :slot :initform nil :unknown keywords :and values)))
You are a Common Lisp macro expert. Given this code pattern:
(def-dynenv-fun nil
    (progn))

Write a macro that addresses: Macro call that should be transformed by DEF-DYNENV-FUN

Macro definition:
(defmacro DEF-DYNENV-FUN ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defun nil (&rest #:args) (apply (dynenv-function nil) #:args))
  (defvar #:nil144 (lambda (progn)))
  (setf (get 'nil 'dynenv-fun) '#:nil144))
Write a Common Lisp macro to handle this code pattern:
(mapping nil (progn))

Problem: Macro call that should be transformed by MAPPING

Macro definition:
(defmacro MAPPING ...)

Macroexpansion:
(mapping-mac nil
  (progn))
Create a Common Lisp macro for the following transformation. Before code:
(defsyntax nil
  nil)

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

Macro definition:
(defmacro defsyntax (name &body options)
  `(progn
     (setf (get ',name :options) ',options)
     (defvar ,name (defreadtable ,name ,@options))))

Macroexpansion:
(progn
 (setf (get 'nil :options) '(nil))
 (defvar nil
   (defreadtable nil
     nil)))
Write a Common Lisp macro to handle this code pattern:
(builder (:auth-basic :authenticator (lambda (user pass) (declare (ignore user pass)) t)) *app*)

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 (#:app174) (funcall (find-middleware :auth-basic) #:app174 :authenticator (lambda (user pass) (declare (ignore user pass)) t))))) :initial-value (to-app *app*) :from-end t)
Define a macro that eliminates this repetitive pattern:
(defclass/a dbi-connection () ((auto-commit :type boolean :initarg :auto-commit :initform t) (database-name :initarg :database-name :accessor connection-database-name) (%handle :initarg :handle :accessor connection-handle) (query-cache :initform (make-hash-table :test 'equal) :accessor connection-query-cache) (established-at :initarg :established-at :initform (get-internal-real-time) :accessor connection-established-at)) (:documentation "Base class for managing DB connection."))

Issue: 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 dbi-connection nil ((auto-commit :type boolean :initarg :auto-commit :initform t) (database-name :initarg :database-name :accessor connection-database-name) (%handle :initarg :handle :accessor connection-handle) (query-cache :initform (make-hash-table :test (quote equal)) :accessor connection-query-cache) (established-at :initarg :established-at :initform (get-internal-real-time) :accessor connection-established-at)) (:documentation "Base class for managing DB connection.")) (deftype <dbi-connection> nil (quote dbi-connection)) (setf (find-class (quote <dbi-connection>)) (find-class (quote dbi-connection))))
You are a Common Lisp macro expert. Given this code pattern:
(with-cached-reader-conditionals
  nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by WITH-CACHED-READER-CONDITIONALS

Macro definition:
(defmacro WITH-CACHED-READER-CONDITIONALS ...)

Macroexpansion:
(call-with-cached-reader-conditionals (lambda () nil (progn)))
Create a Common Lisp macro for the following transformation. Before code:
(with-yield-binds (format nil "~A(~{~A~^, ~})" (sql-op-name op) (mapcar #'yield (function-op-expressions op))))

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

Macro definition:
(defmacro with-yield-binds (&body body)
  `(let ((*bind-values* nil)
         (*use-global-bind-values* t))
     (values
      (progn ,@body)
      (loop for bind in (reverse *bind-values*)
            append bind))))

Macroexpansion:
(let ((*bind-values* nil) (*use-global-bind-values* t)) (values (progn (format nil "~A(~{~A~^, ~})" (sql-op-name op) (mapcar (function yield) (function-op-expressions op)))) (loop for bind in (reverse *bind-values*) append bind)))
Create a Common Lisp macro for the following transformation. Before code:
(when-let ((x 1) (y nil) (z 3)) :oops)

What needs to change: 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 1) (y nil) (z 3)) (when (and x y z) :oops))
Create a Common Lisp macro for the following transformation. Before code:
(with-quote-char (sxql:yield sql))

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

Macro definition:
(defmacro with-quote-char (&body body)
  `(let ((sxql:*quote-character* (or sxql:*quote-character*
                                     (connection-quote-character))))
     ,@body))

Macroexpansion:
(let ((*quote-character* (or *quote-character* (connection-quote-character)))) (sxql/sql-type:yield sql))
Write a Common Lisp macro to handle this code pattern:
(with-fixtures (fixtures test) (call-next-method))

Problem: Macro call that should be transformed by with-fixtures

Macro definition:
(defmacro with-fixtures (fixtures &body body)
  `(call-with-fixtures (lambda () ,@body) ,fixtures))

Macroexpansion:
(call-with-fixtures (lambda nil (call-next-method)) (fixtures test))
Write a Common Lisp macro to handle this code pattern:
(-> nil () 0)

Problem: Macro call that should be transformed by ->

Macro definition:
(defmacro -> (invariant &body args)
  "See flow:atomically"
  `(atomically ,invariant ,@args))

Macroexpansion:
(atomically nil nil 0)
Create a Common Lisp macro for the following transformation. Before code:
(when-let* ((x 2) (y x)) (+ x y))

What needs to change: 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 2)) (when x (let ((y x)) (when y (progn (+ x y))))))
Generate a defmacro form that transforms code like this:
(defpsmacro nil
    (progn))

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

Macro definition:
(defmacro DEFPSMACRO ...)

Macroexpansion:
(progn
 nil
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (setf (gethash 'nil *macro-toplevel*)
           (lambda (#:|ps-macro-form-arg-195|)
             (destructuring-bind (progn) (cdr #:|ps-macro-form-arg-195|))))
   (setf (gethash 'nil *macro-toplevel-lambda-list*) '(progn))
   'nil))
You are a Common Lisp macro expert. Given this code pattern:
(define-error duplicate-name () (name) "This name appears more than once in this form list ~a" name)

Write a macro that addresses: 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 duplicate-name (:error-type varjo-error :prefix "Varjo") (name) "This name appears more than once in this form list ~a" name)
Create a Common Lisp macro for the following transformation. Before code:
(defgenerator compress (data selectors) "Moves through the data and selectors generators in parallel, only yielding elements of data that are paired with a value from selectors that evaluates to true. Eg: (compress (list->generator '(a b c d e f)) (list->generator '(t nil t nil t t))) -> a c e f" (do-generator (d s (izip data selectors)) (when s (yield d))))

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 compress (data selectors) "Moves through the data and selectors generators in parallel, only yielding elements of data that are paired with a value from selectors that evaluates to true. Eg: (compress (list->generator '(a b c d e f)) (list->generator '(t nil t nil t t))) -> a c e f" (with-yield (do-generator (d s (izip data selectors)) (when s (yield d)))))
Write a Common Lisp macro to handle this code pattern:
(defcategory :error (or :error :critical))

Problem: 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 (quote :error) (quote (or :error :critical)) nil)