j14i/cl-macros huggingface dataset:
Generate a defmacro form that transforms code like this:
(insert-char-class-tester (regex (schar *string* curr-pos)) (constant-repetition-constant-length-closure (and (char-class-test) (1+ curr-pos))))

Pattern to recognize: 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-class161 regex)) (let ((#:test-function162 (test-function #:char-class161))) (constant-repetition-constant-length-closure (and (funcall #:test-function162 (schar *string* curr-pos)) (1+ curr-pos)))))
You are a Common Lisp macro expert. Given this code pattern:
(define-error if-branch-type-mismatch (:error-type varjo-critical-error) (then-obj) "Type mismatch: else-case is nil which is of bool type, yet the then form is of ~s type." (type->type-spec (primary-type then-obj)))

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 if-branch-type-mismatch (:error-type varjo-critical-error :prefix "Varjo") (then-obj) "Type mismatch: else-case is nil which is of bool type, yet the then form is of ~s type." (type->type-spec (primary-type then-obj)))
Generate a defmacro form that transforms code like this:
(with-html-string (:div :class "last-update col-xs-2 col-md-1" :title "Last updated 232 days ago" "232d"))

Pattern to recognize: 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 (:div :class "last-update col-xs-2 col-md-1" :title "Last updated 232 days ago" "232d")))
Create a Common Lisp macro for the following transformation. Before code:
(define-cfun c-free)

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

Macro definition:
(defmacro define-cfun (name-or-function &optional (package *package*))
  (when-let ((fun (find-function name-or-function)))
    (with-wrap-attempt ("function ~S" name-or-function) name-or-function
      (with-slots (name type c-symbol fields) fun
        (let* ((fun-name (intern (symbol-name name) package))
               (param-names (mapcar #'foreign-type-name fields))
               (param-syms (mapcar (lambda (x) (gensym (symbol-name x))) param-names))
               (make-function-p (not (foreign-function-variadic-p fun)))
               (maybe-cbv-return
                 (when (cbv-return-p fun)
                   (list 'return-value))))
          (with-gensyms (!fun !fields rest)
            (let ((form
                    (if make-function-p
                        `(defun ,fun-name (,@maybe-cbv-return
                                           ,@param-names ,@(when (foreign-function-variadic-p fun) `(&rest ,rest)))
                           ,@(when maybe-cbv-return `((declare (ignorable ,@maybe-cbv-return))))
                           ,(let ((!fun (find-function name-or-function)))
                              (with-slots ((!fields fields)) !fun
                                (foreign-to-ffi
                                 (and (car !fields) (foreign-type (car !fields)))
                                 param-syms
                                 param-names
                                 !fields
                                 (make-foreign-funcall !fun (and maybe-cbv-return 'return-value)
                                                       param-syms (when (foreign-function-variadic-p fun) rest))))))
                        `(defmacro ,fun-name (,@maybe-cbv-return
                                              ,@param-names ,@(when (foreign-function-variadic-p fun) `(&rest ,rest)))
                           ,@(when maybe-cbv-return `((declare (ignorable ,@maybe-cbv-return))))
                           (let ((,!fun (find-function ',name-or-function)))
                             (with-slots ((,!fields fields)) ,!fun
                               (foreign-to-ffi
                                (and (car ,!fields) (foreign-type (car ,!fields)))
                                ',param-syms
                                (list ,@param-names)
                                ,!fields
                                (make-foreign-funcall ,!fun ,(and maybe-cbv-return 'return-value)
                                                      ',param-syms ,(when (foreign-function-variadic-p fun) rest)))))))))
              `(progn
                 ,@(when (foreign-function-cbv-p fun)
                     (list (funcall *build-libffi-definition* fun)))
                 ,form))))))))

Macroexpansion:
(progn (defun c-free (ptr) (let ((#:ptr209 ptr)) (declare (ignorable #:ptr209)) (cffi-sys:%foreign-funcall "free" (:pointer #:ptr209 :void) :convention :cdecl))))
Create a Common Lisp macro for the following transformation. Before code:
(defclass/std foo2 () ((bar baz)))

What needs to change: 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 foo2 nil ((bar :accessor bar :initarg :bar :initform nil) (baz :accessor baz :initarg :baz :initform nil)))
Write a Common Lisp macro to handle this code pattern:
(decf nil)

Problem: Macro call that should be transformed by DECF

Macro definition:
(defmacro DECF ...)

Macroexpansion:
(setq nil (sb-impl::xsubtract 1 nil))
Create a Common Lisp macro for the following transformation. Before code:
(collect-file nil (progn))

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

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

Macroexpansion:
(common-lisp:let* ((#:generator-551 (generator (progn)))
                   #:items-545
                   (#:out-547 t))
  (declare (type generator #:generator-551)
           (type boolean #:out-547))
  (with-open-file (#:outfile-544 nil :direction :output)
    (tagbody
     #:ll-552
      (setq #:items-545 (next-in #:generator-551 (go end)))
      (common-lisp:funcall #'print #:items-545 #:outfile-544)
      (go #:ll-552)
     end))
  #:out-547)
Define a macro that eliminates this repetitive pattern:
(form-fiddle:lambda-declarations `(lambda () ,@body))

Issue: Macro call that should be transformed by for

Macro definition:
(defmacro for (&environment env bindings &body body)
  (let ((*environment* env))
    (multiple-value-bind (bind-init bind-forms bind-exit bind-post) (convert-bindings bindings)
      (multiple-value-bind (clause-init body-forms clause-exit) (convert-clauses body)
        `(with-interleaving
           ,@bind-init
           ,@clause-init
           (with-for-block ()
             (with-for-tagbody
                 (progn ,@bind-forms
                        ,@body-forms
                        ,@bind-post)
               (return-for
                ,@clause-exit
                ,@bind-exit))))))))

Macroexpansion:
(form-fiddle:lambda-declarations (sb-int:quasiquote (lambda nil #S(sb-impl::comma :expr body :kind 2))))
You are a Common Lisp macro expert. Given this code pattern:
(builder (:session :store (make-redis-store :namespace *namespace* :connection *connection* :expires 3)) (lambda (env) (unless (gethash :user (getf env :lack.session)) (setf (gethash :user (getf env :lack.session)) "深町英太郎")) (unless (gethash :counter (getf env :lack.session)) (setf (gethash :counter (getf env :lack.session)) 0)) `(200 (:content-type "text/plain") (,(format nil "Hello, ~A! You've been here for ~Ath times!" (gethash :user (getf env :lack.session)) (incf (gethash :counter (getf env :lack.session))))))))

Write a macro that addresses: 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 (#:app242) (funcall (find-middleware :session) #:app242 :store (make-redis-store :namespace *namespace* :connection *connection* :expires 3))))) :initial-value (to-app (lambda (env) (unless (gethash :user (getf env :lack.session)) (setf (gethash :user (getf env :lack.session)) "深町英太郎")) (unless (gethash :counter (getf env :lack.session)) (setf (gethash :counter (getf env :lack.session)) 0)) (sb-int:quasiquote (200 (:content-type "text/plain") (#S(sb-impl::comma :expr (format nil "Hello, ~A! You've been here for ~Ath times!" (gethash :user (getf env :lack.session)) (incf (gethash :counter (getf env :lack.session)))) :kind 0)))))) :from-end t)
Define a macro that eliminates this repetitive pattern:
(with-form-fields (name) form (print (field-value name)))

Issue: Macro call that should be transformed by with-form-fields

Macro definition:
(defmacro with-form-fields (fields form &body body)
  "Bind FIELDS to the form fields in FORM.

Example:

@lisp
(with-form-fields (name) form
   (print (field-value name)))
@end lisp

Also see: WITH-FORM-FIELD-VALUES "
  `(let ,(loop for field in fields
               collect `(,field (get-field ,form ',field)))
     ,@body))

Macroexpansion:
(let ((name (get-field form (quote name)))) (print (field-value name)))
Generate a defmacro form that transforms code like this:
(augment-lexenv! :variable whole-var lexenv)

Pattern to recognize: Macro call that should be transformed by augment-lexenv!

Macro definition:
(defmacro augment-lexenv! (kind name env &rest other-datum)
  `(setf ,env (augment-lexenv ,kind ,name ,env ,@other-datum)))

Macroexpansion:
(setf lexenv (augment-lexenv :variable whole-var lexenv))
You are a Common Lisp macro expert. Given this code pattern:
(define-error setq-type-match (:error-type varjo-critical-error) (var-name old-value new-value) "Currently varjo cannot handle changing the type through a setq due to the static nature of glsl. var name: ~a type-of ~a: ~a type-of new-value: ~a" var-name var-name (v-type-of old-value) (primary-type new-value))

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 setq-type-match (:error-type varjo-critical-error :prefix "Varjo") (var-name old-value new-value) "Currently varjo cannot handle changing the type through a setq due to the static nature of glsl. var name: ~a type-of ~a: ~a type-of new-value: ~a" var-name var-name (v-type-of old-value) (primary-type new-value))
You are a Common Lisp macro expert. Given this code pattern:
(enable-quasi-quoted-bivalent-syntax)

Write a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BIVALENT-SYNTAX

Macro definition:
(defmacro ENABLE-QUASI-QUOTED-BIVALENT-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-quasi-quoted-bivalent-syntax-in-readtable :start-character nil
                                                 :end-character nil
                                                 :unquote-character #\COMMA
                                                 :splice-character
                                                 #\COMMERCIAL_AT
                                                 :destructive-splice-character
                                                 #\FULL_STOP
                                                 :transformation-pipeline nil
                                                 :dispatched-quasi-quote-name
                                                 "biv")
  (values))
Write a Common Lisp macro to handle this code pattern:
(define-errno-symbol ERANGE)

Problem: Macro call that should be transformed by define-errno-symbol

Macro definition:
(defmacro define-errno-symbol (name)
  `(defparameter ,name
     (find-errno-symbol (string ',name))))

Macroexpansion:
(defparameter erange (find-errno-symbol (string (quote erange))))
Generate a defmacro form that transforms code like this:
(defpattern cons (a b) (with-gensyms (it) `(guard1 (,it :type cons) (consp ,it) (car ,it) ,a (cdr ,it) ,b)))

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

Macro definition:
(defmacro defpattern (name args &body body)
  "Adds a new derived pattern.
The default value of &optional arguments are '_, instead of nil."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (symbol-pattern ',name)
           #+sbcl
           (sb-int:named-lambda ',name ,(process-lambda-args args) ,@body)
           #-sbcl
           (lambda ,(process-lambda-args args) ,@body))
     ,@(when (stringp (first body))
         ;; lisp-namespace
         `((setf (documentation ',name 'pattern)
                 ,(let ((*print-pretty* t))
                    #-clisp
                    (format nil "~<Lambda-List: ~s~
                                 ~:@_~<  ~@;~a~:>~
                                 ~:@_Defined in ~a~
                               ~:>"
                            (list args (list (first body)) *compile-file-pathname*))
                    #+clisp
                    (format nil "Lambda-List: ~s~%~a"
                            args (first body))))))))

Macroexpansion:
(%defpattern cons (quote a) (quote b) (lambda (with-gensyms (it) (quasiquote (guard1 (#S(sb-impl::comma :expr it :kind 0) :type cons) (consp #S(sb-impl::comma :expr it :kind 0)) (car #S(sb-impl::comma :expr it :kind 0)) #S(sb-impl::comma :expr a :kind 0) (cdr #S(sb-impl::comma :expr it :kind 0)) #S(sb-impl::comma :expr b :kind 0))))))
Define a macro that eliminates this repetitive pattern:
(aif (eval `(and ,(incf x) nil)) :never (list it x))

Issue: Macro call that should be transformed by aif

Macro definition:
(defmacro aif (test then &optional else)
  "Like IF, except binds the result of the test to IT (via LET) for
the scope of the then and else expressions."  
  `(anaphoric if ,test ,then ,else))

Macroexpansion:
(anaphoric if (eval (sb-int:quasiquote (and #S(sb-impl::comma :expr (incf x) :kind 0) nil))) :never (list it x))
You are a Common Lisp macro expert. Given this code pattern:
(caching-types
  nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by CACHING-TYPES

Macro definition:
(defmacro CACHING-TYPES ...)

Macroexpansion:
(call-with-disjoint-hash
 (lambda ()
   (call-with-subtype-hash
    (lambda ()
      (call-with-equiv-hash
       (lambda () (call-with-subtypep-cache (lambda () nil (progn)))))))))
Create a Common Lisp macro for the following transformation. Before code:
(fnn nil nil)

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

Macro definition:
(defmacro FNN ...)

Macroexpansion:
(lambda () nil)
Define a macro that eliminates this repetitive pattern:
(cond->
  nil
  :key
  nil)

Issue: Macro call that should be transformed by COND->

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

Macroexpansion:
(let* ((#:var131 nil)
       (#:var132
        (if :key
            (->
              #:var131)
            #:var131))
       (#:var133
        (if nil
            (->
              #:var132)
            #:var132)))
  #:var133)
Create a Common Lisp macro for the following transformation. Before code:
(ignore-errors nil)

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

Macro definition:
(defmacro IGNORE-ERRORS ...)

Macroexpansion:
(handler-case (progn nil) (error (condition) (values nil condition)))
You are a Common Lisp macro expert. Given this code pattern:
(~> (-> :one () (increment)) (-> :two () (increment)) (-> :three () (increment)))

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

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

Macroexpansion:
(concurrently (-> :one nil (increment)) (-> :two nil (increment)) (-> :three nil (increment)))
Create a Common Lisp macro for the following transformation. Before code:
(define-error cannot-compile () (code) "Cannot compile the following code:~%~a" code)

What needs to change: 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 cannot-compile (:error-type varjo-error :prefix "Varjo") (code) "Cannot compile the following code:~%~a" code)
You are a Common Lisp macro expert. Given this code pattern:
(some-<>> 'some-name)

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

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

Macroexpansion:
(let* ((#:g134 'some-name))
  #:g134)
You are a Common Lisp macro expert. Given this code pattern:
(gatherlet nil
  :key
  nil)

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

Macro definition:
(defmacro GATHERLET ...)

Macroexpansion:
(common-lisp:let ()
  :key
  nil)
You are a Common Lisp macro expert. Given this code pattern:
(make-obsolete mustache-version version "0.10.0")

Write a macro that addresses: Macro call that should be transformed by make-obsolete

Macro definition:
(defmacro make-obsolete (obsolete-name current-name when)
  `(defun ,obsolete-name (&rest args)
     ,(documentation current-name 'function)
     (warn 'deprecation-warning
           :name ',obsolete-name :replacement ',current-name :since ,when)
     (apply ',current-name args)))

Macroexpansion:
(defun mustache-version (&rest args) #A((31) base-char . "Return the CL-MUSTACHE version.") (warn (quote deprecation-warning) :name (quote mustache-version) :replacement (quote version) :since "0.10.0") (apply (quote version) args))
You are a Common Lisp macro expert. Given this code pattern:
(secase (car x) (:y :no))

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

Macro definition:
(defmacro secase (keyform &body cases)
  "Like ECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for the
scope of the cases. IT can be set with SETF."
  `(symbolic ecase ,keyform ,@cases))

Macroexpansion:
(symbolic ecase (car x) (:y :no))
You are a Common Lisp macro expert. Given this code pattern:
(do+ (for x (across #(1 2 3 4) :index index)) (for k (in '(a b c d e))) (returning (list x k :index index)))

Write a macro that addresses: 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 x (across #(1 2 3 4) :index index)) (for k (in (quote (a b c d e)))) (returning (list x k :index index)))
Write a Common Lisp macro to handle this code pattern:
(with* nil
  :key
  nil)

Problem: Macro call that should be transformed by WITH*

Macro definition:
(defmacro WITH* ...)

Macroexpansion:
(progn :key nil)
Define a macro that eliminates this repetitive pattern:
(define-direct-binding unless (var test sub-binding &rest args) (multiple-value-bind (init body value) (apply (binding sub-binding) var args) (values init `(unless ,test ,body) value)))

Issue: Macro call that should be transformed by define-direct-binding

Macro definition:
(defmacro define-direct-binding (name args &body body)
  (let ((env (or (lambda-fiddle:environment-lambda-var args) (gensym "ENVIRONMENT"))))
    `(progn (setf (binding ',name)
                  (lambda ,(lambda-fiddle:remove-environment-part args)
                    (let ((,env *environment*))
                      (declare (ignorable ,env))
                      ,@body)))
            ',name)))

Macroexpansion:
(progn (setf (binding (quote unless)) (lambda (var test sub-binding &rest args) (let ((#:environment126 *environment*)) (declare (ignorable #:environment126)) (multiple-value-bind (init body value) (apply (binding sub-binding) var args) (values init (sb-int:quasiquote (unless #S(sb-impl::comma :expr test :kind 0) #S(sb-impl::comma :expr body :kind 0))) value))))) (quote unless))
You are a Common Lisp macro expert. Given this code pattern:
(enable-dot-syntax)

Write a macro that addresses: Macro call that should be transformed by ENABLE-DOT-SYNTAX

Macro definition:
(defmacro enable-dot-syntax ()
  "Enable reader syntax."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
    (%enable-dot-syntax)))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (%enable-dot-syntax))
Write a Common Lisp macro to handle this code pattern:
(with-unique-names (repeat) `(block nil (tagbody ,repeat ,@*body* (go ,repeat))))

Problem: Macro call that should be transformed by with-unique-names

Macro definition:
(defmacro with-unique-names (names &body body)
  `(let ,(mapcar (lambda (sym)
                   `(,sym (gensym ,(symbol-name sym))))
                  names)
     ,@body))

Macroexpansion:
(let ((repeat (gensym #A((6) base-char . "REPEAT")))) (quasiquote (block nil (tagbody #S(sb-impl::comma :expr repeat :kind 0) #S(sb-impl::comma :expr *body* :kind 2) (go #S(sb-impl::comma :expr repeat :kind 0))))))
Generate a defmacro form that transforms code like this:
(with-flow-function-macro (body-fu lambda-list body) `(dispatch-atomically ,flow-context #',body-fu ,invariant ,@opts))

Pattern to recognize: Macro call that should be transformed by with-flow-function-macro

Macro definition:
(defmacro with-flow-function-macro ((fu-name fu-lambda-list fu-body) &body body)
  `(with-gensyms (,fu-name)
     `(%with-flow-function (,,fu-name ,,fu-lambda-list ,@,fu-body)
        ,,@body)))

Macroexpansion:
(with-gensyms (body-fu) (sb-int:quasiquote (%with-flow-function (#S(sb-impl::comma :expr body-fu :kind 0) #S(sb-impl::comma :expr lambda-list :kind 0) #S(sb-impl::comma :expr body :kind 2)) #S(sb-impl::comma :expr (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))))