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

Pattern to recognize: Macro call that should be transformed by PS-HTML

Macro definition:
(defmacro PS-HTML ...)

Macroexpansion:
(stringify "someName")
You are a Common Lisp macro expert. Given this code pattern:
(f_%
  nil
  nil)

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

Macro definition:
(defmacro F_% ...)

Macroexpansion:
(lambda (&rest #:|ignore127|) (declare (ignore #:|ignore127|)) nil nil)
Create a Common Lisp macro for the following transformation. Before code:
(*> +maybe-many-comments+ +opt-fws+)

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 (#:*>-offset146) (multiple-value-bind (#:*>-res147 #:*>-next148) (funcall +maybe-many-comments+ #:*>-offset146) (if (ok? #:*>-res147) (funcall +opt-fws+ #:*>-next148) (fail #:*>-next148))))
You are a Common Lisp macro expert. Given this code pattern:
(fmap #'nreverse (recurse '() offset))

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

Macro definition:
(defmacro fmap (f thing)
  "Apply a pure function to the inner contents of some parsing operation, if the
parsing itself was successful."
  `(multiple-value-bind (res next) ,thing
     (if (failure? res)
         (fail next)
         (values (funcall ,f res) next))))

Macroexpansion:
(multiple-value-bind (res next) (recurse (quote nil) offset) (if (failure? res) (fail next) (values (funcall (function nreverse) res) next)))
Define a macro that eliminates this repetitive pattern:
(ps-inline nil)

Issue: Macro call that should be transformed by PS-INLINE

Macro definition:
(defmacro PS-INLINE ...)

Macroexpansion:
(concatenate 'string "javascript:" "null")
Write a Common Lisp macro to handle this code pattern:
(with-unique-names (value) (values `((,name (,value) (rplacd ,tail (setq ,tail (cons ,value nil))))) `((inline ,name))))

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 ((value (gensym #A((5) base-char . "VALUE")))) (values (quasiquote ((#S(sb-impl::comma :expr name :kind 0) (#S(sb-impl::comma :expr value :kind 0)) (rplacd #S(sb-impl::comma :expr tail :kind 0) (setq #S(sb-impl::comma :expr tail :kind 0) (cons #S(sb-impl::comma :expr value :kind 0) nil)))))) (quasiquote ((inline #S(sb-impl::comma :expr name :kind 0))))))
Create a Common Lisp macro for the following transformation. Before code:
(defclause previous (expr) "On every iteration, the for-variable is set to the value <expr> had at the end of the previous iteration (initially NIL)." (let ((tmp (gensym (format nil "~A-~A" '#:previous expr)))) (list (make-simple-iteration :step tmp) (make-simple-iteration :var tmp) (make-epilogue :form `(setf ,tmp ,expr)))))

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

Macro definition:
(defmacro defclause (name arglist &body body)
  "Same as cl:defmacro, but additionally records <name> in *clauses* as a known clause macro."
  `(progn
     (defmacro ,name ,arglist ,@body)
     (pushnew ',name *clauses*)))

Macroexpansion:
(progn (defmacro previous (expr) "On every iteration, the for-variable is set to the value <expr> had at the end of the previous iteration (initially NIL)." (let ((tmp (gensym (format nil "~A-~A" (quote #:previous) expr)))) (list (make-simple-iteration :step tmp) (make-simple-iteration :var tmp) (make-epilogue :form (sb-int:quasiquote (setf #S(sb-impl::comma :expr tmp :kind 0) #S(sb-impl::comma :expr expr :kind 0))))))) (pushnew (quote previous) *clauses*))
Create a Common Lisp macro for the following transformation. Before code:
(aand 1 (values t it))

What needs to change: 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 (values t it))
Generate a defmacro form that transforms code like this:
(define-custom-var (:boolean *boolean-handler*) (constantly t) "Designator for a function of 1 string argument (boolean token).")

Pattern to recognize: 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 (*boolean-handler* . :boolean)) *custom-vars* :test (function equal)) (defvar *boolean-handler* (constantly t) "Designator for a function of 1 string argument (boolean token).")))
Write a Common Lisp macro to handle this code pattern:
(->* nil :key nil)

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

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

Macroexpansion:
(-> nil nil :key)
Write a Common Lisp macro to handle this code pattern:
(flow-lambda-macro (flow-context) `(dispatch-serially ,flow-context ,flow-list))

Problem: 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 (sb-int:quasiquote (dispatch-serially #S(sb-impl::comma :expr flow-context :kind 0) #S(sb-impl::comma :expr flow-list :kind 0))) :kind 0))))
Define a macro that eliminates this repetitive pattern:
(dreletf* nil
  (progn))

Issue: Macro call that should be transformed by DRELETF*

Macro definition:
(defmacro DRELETF* ...)

Macroexpansion:
(progn (progn))
Generate a defmacro form that transforms code like this:
(define-modf-rewrite cadaar (expr) `(car (cdaar ,(second expr))))

Pattern to recognize: Macro call that should be transformed by define-modf-rewrite

Macro definition:
(defmacro define-modf-rewrite (name (expr) &body body)
  "Define a new rewrite rule.  If a form starting with NAME is encountered, call
the defined function to return a form that we can deal with (i.e. one defined
via DEFINE-MODF-EXPANDER, DEFINE-MODF-FUNCTION, and DEFINE-MODF-METHOD)."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (gethash ',name *modf-rewrites*)
           (lambda (,expr)
             ,@body))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote cadaar) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (car (cdaar #S(sb-impl::comma :expr (second expr) :kind 0)))))))
Generate a defmacro form that transforms code like this:
(the nil)

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

Macro definition:
(defmacro THE ...)

Macroexpansion:
(send self nil)
You are a Common Lisp macro expert. Given this code pattern:
(check-declaration-env 'some-name)

Write a macro that addresses: Macro call that should be transformed by CHECK-DECLARATION-ENV

Macro definition:
(defmacro CHECK-DECLARATION-ENV ...)

Macroexpansion:
(let ((#:some-name122 some-name))
  (let ((#:new121 (%check-declaration-env '#:some-name122 nil nil)))
    (funcall #'(setf quote) #:new121 #:some-name122)))
Define a macro that eliminates this repetitive pattern:
(with-dynenv nil
  :key
  nil)

Issue: Macro call that should be transformed by WITH-DYNENV

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

Macroexpansion:
(multiple-value-bind (#:var-expansion134 #:var-expanded-p135)
    (macroexpand-1 'var-space nil)
  (multiple-value-bind (#:fun-expansion136 #:fun-expanded-p137)
      (macroexpand-1 'fun-space nil)
    (let ((*var-space* (when #:var-expanded-p135 #:var-expansion134))
          (*fun-space* (when #:fun-expanded-p137 #:fun-expansion136))
          (*within-captured-dynenv* t))
      :key
      nil)))
Generate a defmacro form that transforms code like this:
(set-dynamic nil nil)

Pattern to recognize: Macro call that should be transformed by SET-DYNAMIC

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

Macroexpansion:
(setf (dynamic nil) nil)
Generate a defmacro form that transforms code like this:
(collect-min nil :key nil)

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

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

Macroexpansion:
(common-lisp:let* ((#:generator-312 (generator :key))
                   #:items-302
                   (#:generator-310 (generator nil))
                   #:numbers-301
                   (#:number-304 nil)
                   #:result-305)
  (declare (type generator #:generator-312)
           (type generator #:generator-310)
           (type (null-or t) #:result-305))
  (tagbody
   #:ll-313
    (setq #:items-302 (next-in #:generator-312 (go end)))
    (setq #:numbers-301 (next-in #:generator-310 (go end)))
    (if (or (null #:number-304) (> #:number-304 #:numbers-301))
        (setq #:number-304 #:numbers-301
              #:result-305 #:items-302))
    (go #:ll-313)
   end)
  (if (null #:number-304)
      (setq #:result-305 nil))
  #:result-305)
You are a Common Lisp macro expert. Given this code pattern:
(defclass/a dbd-sqlite3 (dbi-driver) ())

Write a macro that addresses: 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 (dbi-driver) nil) (deftype <dbd-sqlite3> nil (quote dbd-sqlite3)) (setf (find-class (quote <dbd-sqlite3>)) (find-class (quote dbd-sqlite3))))
Define a macro that eliminates this repetitive pattern:
(with-preprocessor-state-slots (state) (and (zerop tokens-in-line) (or (token-equal-p token "#") (and *with-c-syntax-preprocessor-process-digraph* (token-equal-p token "%:")))))

Issue: Macro call that should be transformed by with-preprocessor-state-slots

Macro definition:
(defmacro with-preprocessor-state-slots ((state) &body body)
  `(with-accessors ((file-pathname pp-state-file-pathname)
                    (token-list pp-state-token-list)
                    (result-list pp-state-result-list)
                    (line-number pp-state-line-number)
                    (tokens-in-line pp-state-tokens-in-line)
                    (macro-alist pp-state-macro-alist)
                    (if-section-stack pp-state-if-section-stack)
                    (if-section-skip-reason pp-state-if-section-skip-reason)
                    (include-stack pp-state-include-stack))
       ,state
     ,@body))

Macroexpansion:
(with-accessors ((file-pathname pp-state-file-pathname) (token-list pp-state-token-list) (result-list pp-state-result-list) (line-number pp-state-line-number) (tokens-in-line pp-state-tokens-in-line) (macro-alist pp-state-macro-alist) (if-section-stack pp-state-if-section-stack) (if-section-skip-reason pp-state-if-section-skip-reason) (include-stack pp-state-include-stack)) state (and (zerop tokens-in-line) (or (token-equal-p token "#") (and *with-c-syntax-preprocessor-process-digraph* (token-equal-p token "%:")))))
You are a Common Lisp macro expert. Given this code pattern:
(lret* ((type `(integer 0 (,end))) (vector (make-array end :element-type type :initial-element 0))) (nlet lp ((i 0)) (declare (type array-index i)) (if (= i end) vector (progn (setf (aref vector i) i) (lp (1+ i))))))

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

Macro definition:
(defmacro lret ((&rest bindings) &body body)
  "Return the initial value of the last binding in BINDINGS. The idea
is to create something, initialize it, and then return it.

    (lret ((x 1)
           (y (make-array 1)))
      (setf (aref y 0) x))
    => #(1)

Note that the value returned is the value initially bound. Subsequent
assignments are ignored.

    (lret ((x 1))
      (setf x 2))
    => 1

Furthermore, on Lisps that support it, the variable may be made
read-only, making assignment a compiler-time error.

`lret' may seem trivial, but it fufills the highest purpose a macro
can: it eliminates a whole class of bugs (initializing an object, but
forgetting to return it).

Cf. `aprog1' in Anaphora."
  `(lret-aux let ,bindings
     ,@body))

Macroexpansion:
(lret-aux let* ((type (sb-int:quasiquote (integer 0 (#S(sb-impl::comma :expr end :kind 0))))) (vector (make-array end :element-type type :initial-element 0))) (nlet lp ((i 0)) (declare (type array-index i)) (if (= i end) vector (progn (setf (aref vector i) i) (lp (1+ i))))))
Define a macro that eliminates this repetitive pattern:
(integer-reader 2)

Issue: Macro call that should be transformed by integer-reader

Macro definition:
(defmacro integer-reader (bytes)
  "Create a function to read integers from a binary stream."
  (let ((bits (* bytes 8)))
    (labels ((return-form (signed)
               (if signed
                   `(if (logbitp ,(1- bits) result)
                        (dpb result (byte ,(1- bits) 0) -1)
                        result)
                   `result))
             (generate-reader (signed)
               `(defun ,(integer-reader-name bytes signed) (socket)
                  (declare (type stream socket)
                           #.*optimize*)
                  ,(if (= bytes 1)
                       `(let ((result (the (unsigned-byte 8) (read-byte socket))))
                          (declare (type (unsigned-byte 8) result))
                          ,(return-form signed))
                       `(let ((result 0))
                          (declare (type (unsigned-byte ,bits) result))
                          ,@(loop :for byte :from (1- bytes) :downto 0
                                  :collect `(setf (ldb (byte 8 ,(* 8 byte))
                                                       result)
                                                  (the (unsigned-byte 8)
                                                       (read-byte socket))))
                          ,(return-form signed))))))
      `(progn
         ;; This causes weird errors on SBCL in some circumstances. Disabled for now.
         ;;         (declaim (inline ,(integer-reader-name bytes t)
         ;;                          ,(integer-reader-name bytes nil)))
         (declaim (ftype (function (t) (signed-byte ,bits))
                         ,(integer-reader-name bytes t)))
         ,(generate-reader t)
         (declaim (ftype (function (t) (unsigned-byte ,bits))
                         ,(integer-reader-name bytes nil)))
         ,(generate-reader nil)))))

Macroexpansion:
(progn (declaim (ftype (function (t) (signed-byte 16)) read-int2)) (defun read-int2 (socket) (declare (type stream socket) (optimize (speed 3) (safety 0) (space 1) (debug 1) (compilation-speed 0))) (let ((result 0)) (declare (type (unsigned-byte 16) result)) (setf (ldb (byte 8 8) result) (the (unsigned-byte 8) (read-byte socket))) (setf (ldb (byte 8 0) result) (the (unsigned-byte 8) (read-byte socket))) (if (logbitp 15 result) (dpb result (byte 15 0) -1) result))) (declaim (ftype (function (t) (unsigned-byte 16)) read-uint2)) (defun read-uint2 (socket) (declare (type stream socket) (optimize (speed 3) (safety 0) (space 1) (debug 1) (compilation-speed 0))) (let ((result 0)) (declare (type (unsigned-byte 16) result)) (setf (ldb (byte 8 8) result) (the (unsigned-byte 8) (read-byte socket))) (setf (ldb (byte 8 0) result) (the (unsigned-byte 8) (read-byte socket))) result)))
Generate a defmacro form that transforms code like this:
(if-let (x) :oops (not x))

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

Macro definition:
(defmacro if-let (bindings &body (then-form &optional else-form))
    "Creates new variable bindings, and conditionally executes either
THEN-FORM or ELSE-FORM. ELSE-FORM defaults to NIL.

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, the THEN-FORM is executed with the
bindings in effect, otherwise the ELSE-FORM is executed with the bindings in
effect."
    (let* ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
                             (list bindings)
                             bindings))
         (variables (mapcar #'car binding-list)))
    `(let ,binding-list
       (if (and ,@variables)
           ,then-form
           ,else-form))))

Macroexpansion:
(let ((x)) (if (and x) :oops (not x)))
Write a Common Lisp macro to handle this code pattern:
(define-class-method nil
    nil)

Problem: Macro call that should be transformed by DEFINE-CLASS-METHOD

Macro definition:
(defmacro DEFINE-CLASS-METHOD ...)

Macroexpansion:
(progn
 (define-incongruent-method nil
     nil)
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (add-class-principal-method 'nil 'nil)))
You are a Common Lisp macro expert. Given this code pattern:
(f_%
  nil
  :key
  nil)

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

Macro definition:
(defmacro F_% ...)

Macroexpansion:
(lambda (&rest #:|ignore129|) (declare (ignore #:|ignore129|)) nil :key nil)
Create a Common Lisp macro for the following transformation. Before code:
(letrec nil
  (progn))

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

Macro definition:
(defmacro LETREC ...)

Macroexpansion:
(let ()
  (flet ()
    nil
    (setf)
    (progn)))
You are a Common Lisp macro expert. Given this code pattern:
(define-test example :depends-on (dependency) (true T) (false NIL) (is equal "A" (string :a)) (of-type symbol 'foo) (is-values (values 0 "0" 'c) (= 0) (equal "1") (= 2) "This illustrates a multiple value test!"))

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

Macro definition:
(defmacro define-test (name &body arguments-and-body)
  (destructuring-bind (nparent name) (if (listp name) name (list NIL name))
    (form-fiddle:with-body-options (body options parent home (test-class 'test) (compile-at :compile-time) defun) arguments-and-body
      (let ((body (remove 'define-test body :key (lambda (a) (when (listp a) (car a))) :test #'eql))
            (defs (remove 'define-test body :key (lambda (a) (when (listp a) (car a))) :test-not #'eql))
            (home-form (or home `(find-package ,(package-name *package*)))))
        (when (and parent nparent)
          (error "Cannot specify parent through name and through a keyword argument at the same time!"))
        `(let ((*package* (find-package ,(package-name *package*)))) ; Make sure package stays consistent throughout initialisation.
           (setf (find-test ',name ,home-form)
                 (ensure-test ',test-class
                              :name ',name
                              :home ,home-form
                              :tests (list ,@(loop for form in body
                                                   collect (ecase compile-at
                                                             (:compile-time `(lambda () ,form))
                                                             (:execute `(lambda () (call-compile ',form))))))
                              :parent ',(or parent nparent)
                              ,@(loop for option in options
                                      collect `',option)))
           ,@(loop for (def subname . body) in defs
                   collect `(,def (,name ,subname)
                              :home ,home
                              ,@body))
           ,@(when defun
               `((defun ,(if (stringp name) (read-symbol name) name) (&rest test-args)
                   (apply #'test (find-test ',name ,home-form) test-args))))
           ',name)))))

Macroexpansion:
(let ((*package* (find-package #A((9) base-char . "PARACHUTE")))) (setf (find-test (quote example) (find-package #A((9) base-char . "PARACHUTE"))) (ensure-test (quote test) :name (quote example) :home (find-package #A((9) base-char . "PARACHUTE")) :tests (list (lambda nil (true t)) (lambda nil (false nil)) (lambda nil (is equal "A" (string :a))) (lambda nil (of-type symbol (quote foo))) (lambda nil (is-values (values 0 "0" (quote c)) (= 0) (equal "1") (= 2) "This illustrates a multiple value test!"))) :parent (quote nil) (quote :depends-on) (quote (dependency)))) (quote example))
Create a Common Lisp macro for the following transformation. Before code:
(concurrently () (atomically nil () (symbol-name 'this)) (atomically nil () (symbol-name 'is)) (atomically nil () (symbol-name 'meh)))

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

Macro definition:
(defmacro concurrently (&body flow)
  "Executes child elements in parallel, returning a list of results for child
blocks or flows in the same order they were specified. Heavy consing."
  (with-flow-let-macro (flow-list flow)
    (flow-lambda-macro (flow-context)
      `(dispatch-concurrently ,flow-context ,flow-list))))

Macroexpansion:
(let ((#:flow-list157 (list nil (atomically nil nil (symbol-name (quote this))) (atomically nil nil (symbol-name (quote is))) (atomically nil nil (symbol-name (quote meh)))))) (%flow-lambda (#:flow-context158) (dispatch-concurrently #:flow-context158 #:flow-list157)))
Generate a defmacro form that transforms code like this:
(define-filtered-function nil
    (progn))

Pattern to recognize: Macro call that should be transformed by DEFINE-FILTERED-FUNCTION

Macro definition:
(defmacro DEFINE-FILTERED-FUNCTION ...)

Macroexpansion:
(progn
 (defgeneric nil
     (progn)
   (:generic-function-class filtered-function)
   (:method-class filtered-method)
   (:method-combination filtered))
 (setf (generic-function-filters (fdefinition 'nil)) (list))
 'nil)
Write a Common Lisp macro to handle this code pattern:
(cond->>
  'some-name)

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

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

Macroexpansion:
'some-name
Create a Common Lisp macro for the following transformation. Before code:
(some->>
  'some-name)

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

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

Macroexpansion:
'some-name
Define a macro that eliminates this repetitive pattern:
(auto-permute-typecase nil)

Issue: Macro call that should be transformed by AUTO-PERMUTE-TYPECASE

Macro definition:
(defmacro AUTO-PERMUTE-TYPECASE ...)

Macroexpansion:
(typecase nil)
Define a macro that eliminates this repetitive pattern:
(*let nil
  (progn))

Issue: Macro call that should be transformed by *LET

Macro definition:
(defmacro *LET ...)

Macroexpansion:
(let* ()
  (progn))