j14i/cl-macros huggingface dataset:
Generate a defmacro form that transforms code like this:
(without-symbol-access)

Pattern to recognize: Macro call that should be transformed by WITHOUT-SYMBOL-ACCESS

Macro definition:
(defmacro WITHOUT-SYMBOL-ACCESS ...)

Macroexpansion:
(let ((*symbol-access* nil)))
Write a Common Lisp macro to handle this code pattern:
(when (and (not (eql (top-info) 'decl)) (> (length (slot-value (node-slot members) 'nodes)) 3)) (push-sign 'enum-break))

Problem: 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 (and (not (eql (top-info) (quote decl))) (> (length (slot-value (node-slot members) (quote nodes))) 3)) (push-sign (quote enum-break)))
Create a Common Lisp macro for the following transformation. Before code:
(defclause in-list (&whole form list &key (by '(function cdr)) (rest (gensym "REST")) &environment env) "Like IN, but specialized for lists. Successive lists are obtained by calling the function BY (which by default is #'CDR) on the previous list. REST, if specified, is the variable holding the remaining elements to be processed; REST initially is bound to the entire list, then to successive lists obtained by funcalling BY." (if (symbolp *iteration-variable*) (list (make-simple-iteration :var rest :init list :step `(funcall ,by ,rest)) (make-simple-iteration :init `(car ,rest) :step `(car ,rest) :precondition `(not (null ,rest)))) (expand-with-simple-destructuring form env)))

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 in-list (&whole form list &key (by (quote (function cdr))) (rest (gensym "REST")) &environment env) "Like IN, but specialized for lists. Successive lists are obtained by calling the function BY (which by default is #'CDR) on the previous list. REST, if specified, is the variable holding the remaining elements to be processed; REST initially is bound to the entire list, then to successive lists obtained by funcalling BY." (if (symbolp *iteration-variable*) (list (make-simple-iteration :var rest :init list :step (sb-int:quasiquote (funcall #S(sb-impl::comma :expr by :kind 0) #S(sb-impl::comma :expr rest :kind 0)))) (make-simple-iteration :init (sb-int:quasiquote (car #S(sb-impl::comma :expr rest :kind 0))) :step (sb-int:quasiquote (car #S(sb-impl::comma :expr rest :kind 0))) :precondition (sb-int:quasiquote (not (null #S(sb-impl::comma :expr rest :kind 0)))))) (expand-with-simple-destructuring form env))) (pushnew (quote in-list) *clauses*))
Generate a defmacro form that transforms code like this:
(yield-all g)

Pattern to recognize: Macro call that should be transformed by yield-all

Macro definition:
(defmacro yield-all (generator)
  "Walks through generator, re-yielding all of the items in it. Only meant for use inside of a defgenerator or with-yield block."
  (let ((x (gensym)))
    `(do-generator (,x ,generator)
       (yield ,x))))

Macroexpansion:
(do-generator (#:g182 g) (yield #:g182))
Generate a defmacro form that transforms code like this:
(define-op (:% conjunctive-op))

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

Macro definition:
(defmacro define-op ((op-name struct-type &key sql-op-name include-slots (package (find-package '#:sxql/operator))) &body body)
  (check-type op-name symbol)
  (let ((struct-name (intern (concatenate 'string (symbol-name op-name) #.(string :-op)) package)))
    `(defstruct (,struct-name (:include ,struct-type
                               (name ,(or sql-op-name
                                          (with-output-to-string (s)
                                            (loop for c across (symbol-name op-name)
                                                  if (char= c #\-)
                                                    do (write-char #\Space s)
                                                  else
                                                    do (write-char c s)))))
                               ,@include-slots)
                              (:constructor ,(intern (concatenate 'string
                                                                  #.(string :make-)
                                                                  (symbol-name op-name)
                                                                  #.(string :-op))
                                                     package)
                                  ,(ecase struct-type
                                     ((unary-op
                                       unary-splicing-op
                                       unary-postfix-op) '(var))
                                     ((infix-op
                                       infix-splicing-op
                                       infix-list-op) '(left right))
                                     (conjunctive-op '(&rest expressions)))))
       ,@body)))

Macroexpansion:
(defstruct (%-op (:include conjunctive-op (name "%")) (:constructor make-%-op (&rest expressions))))
You are a Common Lisp macro expert. Given this code pattern:
(do-for nil)

Write a macro that addresses: Macro call that should be transformed by DO-FOR

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

Macroexpansion:
(block nil (lc ((block nil (tagbody (return (progn))))) progn))
Define a macro that eliminates this repetitive pattern:
(is-traced$method 'some-name)

Issue: Macro call that should be transformed by IS-TRACED$METHOD

Macro definition:
(defmacro IS-TRACED$METHOD ...)

Macroexpansion:
(mcs-is-traced quote some-name)
Write a Common Lisp macro to handle this code pattern:
(defsynonym counting :count)

Problem: 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 counting) (quote synonym)) (quote :count)))
Create a Common Lisp macro for the following transformation. Before code:
(with-yield
  nil
  nil)

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

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

Macroexpansion:
(isolate-cont
  (enable-yield
    nil
    nil
    nil))
Generate a defmacro form that transforms code like this:
(some-<> nil (progn))

Pattern to recognize: Macro call that should be transformed by SOME-<>

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

Macroexpansion:
(let* ((#:g122 nil))
  (if (null #:g122)
      nil
      (-> #:g122 (progn))))
Write a Common Lisp macro to handle this code pattern:
(defsynonym first-time-p :first-time-p)

Problem: 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 first-time-p) (quote synonym)) (quote :first-time-p)))
You are a Common Lisp macro expert. Given this code pattern:
(builder (:session :store (make-dbi-store :connector (lambda () *conn*) :record-timestamps t)) (lambda (env) (unless (gethash :counter (getf env :lack.session)) (setf (gethash :counter (getf env :lack.session)) 0)) `(200 (:content-type "text/plain") (,(format nil "Hello, you've been here for ~Ath times!" (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 (#:app236) (funcall (find-middleware :session) #:app236 :store (make-dbi-store :connector (lambda nil *conn*) :record-timestamps t))))) :initial-value (to-app (lambda (env) (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, you've been here for ~Ath times!" (incf (gethash :counter (getf env :lack.session)))) :kind 0)))))) :from-end t)
Create a Common Lisp macro for the following transformation. Before code:
(define-simple-definition-resolver setf-expander (designator) (sb-int:info :setf :expander designator))

What needs to change: Macro call that should be transformed by define-simple-definition-resolver

Macro definition:
(defmacro define-simple-definition-resolver (class lookup-function &body body)
  (let ((package (gensym "PACKAGE")))
    `(define-definition-resolver ,class (,class ,package)
       (when (ignore-errors ,(if body
                                 `(let ((,(first lookup-function) ,class))
                                    ,@body)
                                 `(,lookup-function ,class)))
         (list (make-instance ',class :designator ,class :package ,package))))))

Macroexpansion:
(define-definition-resolver setf-expander (setf-expander #:package142) (when (ignore-errors (let ((designator setf-expander)) (sb-int:info :setf :expander designator))) (list (make-instance (quote setf-expander) :designator setf-expander :package #:package142))))
Generate a defmacro form that transforms code like this:
(lambda-match
  nil
  (progn))

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

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

Macroexpansion:
(lambda (#:arg148)
  (match #:arg148
    nil
    (progn)))
You are a Common Lisp macro expert. Given this code pattern:
(with-prepared-query query (conn sql) (or (dbi:fetch-all (dbi:execute query) :format :plist) (error "Table \"~A\" doesn't exist." table-name)))

Write a macro that addresses: 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 conn sql (lambda (query) (or (dbi.driver:fetch-all (dbi.driver:execute query) :format :plist) (error "Table \"~A\" doesn't exist." table-name))) :use-prepare-cached nil)
You are a Common Lisp macro expert. Given this code pattern:
(with-form-html-output (apply #'forms::renderer-render-form-errors renderer theme form args) (:form :id (forms::form-id form) :action (forms::form-action form) :method (symbol-name (forms::form-method form)) :enctype (forms::form-enctype form) :class (getf args :class) :data-parsley-validate (when (forms::client-validation form) "true") (when (forms::form-csrf-protection-p form) (let ((token (forms::set-form-session-csrf-token form))) (htm (:input :name (forms::form-csrf-field-name form) :type "hidden" :value token)))) (loop for field in (forms::form-fields form) do (forms::renderer-render-field renderer theme (cdr field) form))))

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

Macro definition:
(defmacro with-form (form &body body)
  "Bind *FORM* to FORM and evaluate BODY in that context."
  `(call-with-form ,form (lambda () ,@body)))

Macroexpansion:
(with-form-html-output (apply (function renderer-render-form-errors) renderer theme form args) (:form :id (form-id form) :action (form-action form) :method (symbol-name (form-method form)) :enctype (form-enctype form) :class (getf args :class) :data-parsley-validate (when (client-validation form) "true") (when (form-csrf-protection-p form) (let ((token (set-form-session-csrf-token form))) (htm (:input :name (form-csrf-field-name form) :type "hidden" :value token)))) (loop for field in (form-fields form) do (renderer-render-field renderer theme (cdr field) form))))
You are a Common Lisp macro expert. Given this code pattern:
(with-html-string (:div (:div (:div (:div.list-group.toc-entries :data-instant t)))))

Write a macro that addresses: 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 (:div (:div (:div.list-group.toc-entries :data-instant t))))))
Write a Common Lisp macro to handle this code pattern:
(collect-plist nil (progn))

Problem: Macro call that should be transformed by COLLECT-PLIST

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

Macroexpansion:
(common-lisp:let* ((#:generator-200 (generator (progn)))
                   #:values-193
                   (#:generator-198 (generator nil))
                   #:indicators-192
                   (#:plist-194 nil))
  (declare (type generator #:generator-200)
           (type generator #:generator-198)
           (type list #:plist-194))
  (tagbody
   #:ll-201
    (setq #:values-193 (next-in #:generator-200 (go end)))
    (setq #:indicators-192 (next-in #:generator-198 (go end)))
    (setq #:plist-194 (list* #:indicators-192 #:values-193 #:plist-194))
    (go #:ll-201)
   end)
  #:plist-194)
Create a Common Lisp macro for the following transformation. Before code:
(define-error uniform-in-sfunc () (func-name) "Must not have uniforms in shader functions, only appropriate in shader stages: ~a" func-name)

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 uniform-in-sfunc (:error-type varjo-error :prefix "Varjo") (func-name) "Must not have uniforms in shader functions, only appropriate in shader stages: ~a" func-name)
Create a Common Lisp macro for the following transformation. Before code:
(atypecase "Foo" (fixnum :no) (hash-table :nono))

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

Macro definition:
(defmacro atypecase (keyform &body cases)
  "Like TYPECASE, except binds the result of the keyform to IT (via LET) for
the scope of the cases."
  `(anaphoric typecase ,keyform ,@cases))

Macroexpansion:
(anaphoric typecase "Foo" (fixnum :no) (hash-table :nono))
Define a macro that eliminates this repetitive pattern:
(defmethod* nil
    (progn))

Issue: Macro call that should be transformed by DEFMETHOD*

Macro definition:
(defmacro DEFMETHOD* ...)

Macroexpansion:
(defmethod nil (progn) (with-yield))
Create a Common Lisp macro for the following transformation. Before code:
(with-env (setp 3 [plist :e]))

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

Macro definition:
(defmacro with-env (&body body)
  (let ((body-value (gensym)))
    `(let (,body-value)
       (defclass foo () ((a :initform 3)))
       (defmethod get-val ((object foo) &rest slot/s) (slot-value object (car slot/s)))
       (defmethod (setf get-val) (new-value (object foo) &rest slot/s)
         (setf (slot-value object (car slot/s)) new-value))
       (defstruct bar a)
       (setq ,body-value
             (let ((str (alexandria:copy-array "abcde"))
                   (vec (alexandria:copy-array #(a b c d e)))
                   (arr (alexandria:copy-array #2A((1 2 3)
                                                   (4 5 6))))
                   (list      (copy-list '(a b c d e)))
                   (ht        (eval (read-from-string "{'a 'b 'c 'd}")))
                   (ht-eq     (eval (read-from-string "{eq \"a\" 1
                                                    \"b\" 2}")))
                   (ht-equalp (eval (read-from-string "{equalp '(1 2 3) \"a\"
                                                               '(4 5 6) \"b\"}")))
                   (assoc-list (copy-tree '((a . 1) (b . 2))))
                   (plist      (copy-list '(:a 4 :c 5)))
                   (clos-object (make-instance 'foo))
                   (struct      (make-bar :a 3)))
               (declare (ignorable str vec arr list ht ht-eq ht-equalp
                                   assoc-list plist clos-object struct))
               ,@body))
       (setf (find-class 'foo nil) nil)
       (setf (find-class 'bar nil) nil)
       ,body-value))

Macroexpansion:
(let (#:g137) (defclass foo nil ((a :initform 3))) (defmethod get-val ((object foo) &rest slot/s) (slot-value object (car slot/s))) (defmethod (setf get-val) (new-value (object foo) &rest slot/s) (setf (slot-value object (car slot/s)) new-value)) (defstruct bar a) (setq #:g137 (let ((str (alexandria:copy-array "abcde")) (vec (alexandria:copy-array #(a b c d e))) (arr (alexandria:copy-array #2A((1 2 3) (4 5 6)))) (list (copy-list (quote (a b c d e)))) (ht (eval (read-from-string "{'a 'b 'c 'd}"))) (ht-eq (eval (read-from-string "{eq \"a\" 1
                                                    \"b\" 2}"))) (ht-equalp (eval (read-from-string "{equalp '(1 2 3) \"a\"
                                                               '(4 5 6) \"b\"}"))) (assoc-list (copy-tree (quote ((a . 1) (b . 2))))) (plist (copy-list (quote (:a 4 :c 5)))) (clos-object (make-instance (quote foo))) (struct (make-bar :a 3))) (declare (ignorable str vec arr list ht ht-eq ht-equalp assoc-list plist clos-object struct)) (setp 3 [plist :e]))) (setf (find-class (quote foo) nil) nil) (setf (find-class (quote bar) nil) nil) #:g137)
Generate a defmacro form that transforms code like this:
(lret* ((type `(integer ,start (,end))) (len (ceiling (- end start) step)) (vector (make-array len :element-type type :initial-element start))) (nlet lp ((i 0) (n start)) (declare (type array-index i n)) (if (= i len) vector (progn (setf (aref vector i) n) (lp (1+ i) (+ n step))))))

Pattern to recognize: 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 #S(sb-impl::comma :expr start :kind 0) (#S(sb-impl::comma :expr end :kind 0))))) (len (ceiling (- end start) step)) (vector (make-array len :element-type type :initial-element start))) (nlet lp ((i 0) (n start)) (declare (type array-index i n)) (if (= i len) vector (progn (setf (aref vector i) n) (lp (1+ i) (+ n step))))))
Define a macro that eliminates this repetitive pattern:
(with-local-readtable
  nil
  :key
  nil)

Issue: Macro call that should be transformed by WITH-LOCAL-READTABLE

Macro definition:
(defmacro WITH-LOCAL-READTABLE ...)

Macroexpansion:
(bind ((*readtable* (copy-readtable *readtable*)))
  nil
  :key
  nil)
You are a Common Lisp macro expert. Given this code pattern:
(*> +period+ +skip-junk+)

Write a macro that addresses: 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 (#:*>-offset227) (multiple-value-bind (#:*>-res228 #:*>-next229) (funcall +period+ #:*>-offset227) (if (ok? #:*>-res228) (funcall +skip-junk+ #:*>-next229) (fail #:*>-next229))))
Define a macro that eliminates this repetitive pattern:
(with-additional-indent (reporter stream "- ") (let ((description (possible-report-description report))) (when description (format/indent reporter stream description))))

Issue: Macro call that should be transformed by with-additional-indent

Macro definition:
(defmacro with-additional-indent ((reporter stream control-string &rest format-arguments) &body body)
  (declare (ignorable reporter stream control-string))
  (let* ((need-new-line (ppcre:scan "^~&" control-string))
         (string (apply #'format nil control-string format-arguments))
         (increment (length string)))
    `(with-slots (indent-space) reporter
       (let* ((first-line-indent (indent indent-space))
              (*additional-indent* ,(if need-new-line
                                        increment
                                        `(+ *additional-indent*
                                            ,increment))))
         (declare (ignorable first-line-indent))
         ,(if need-new-line
              `(progn (fresh-line stream)
                      (write-string first-line-indent ,stream)
                      ;; because we just started a new line, we
                      ;; should use format/indent to write string
                      ;; taking into account a main indentation level
                      (format/indent ,reporter ,stream ,string))
              ;; otherwise, just output our prefix
              `(write-string ,string ,stream))
       
       
         ,@body))))

Macroexpansion:
(with-slots (indent-space) reporter (let* ((first-line-indent (indent indent-space)) (*additional-indent* (+ *additional-indent* 2))) (declare (ignorable first-line-indent)) (write-string #A((2) base-char . "- ") stream) (let ((description (possible-report-description report))) (when description (format/indent reporter stream description)))))
Generate a defmacro form that transforms code like this:
(define nil
  (progn))

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

Macro definition:
(defmacro DEFINE ...)

Macroexpansion:
(eval-when (:load-toplevel :execute)
  (check-if-bound 'nil)
  (setf (get 'nil 'read-macro)
          (lambda (#:stream147)
            (let ((*standard-input* #:stream147))
              (progn))))
  'nil)
Generate a defmacro form that transforms code like this:
(draw scene (:rect :x 5 :y 5 :height 30 :width 30))

Pattern to recognize: 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 ((#:g142 (funcall (function make-svg-element) :rect (append (list :x 5 :y 5 :height 30 :width 30) (list))))) (add-element scene #:g142) #:g142)
Create a Common Lisp macro for the following transformation. Before code:
(do+ (for x (across #())) (collect x))

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

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

Macroexpansion:
(do+/internal nil (for x (across #())) (collect x))