j14i/cl-macros huggingface dataset:
Define a macro that eliminates this repetitive pattern:
(with-unique-js-names 'some-name)

Issue: Macro call that should be transformed by WITH-UNIQUE-JS-NAMES

Macro definition:
(defmacro WITH-UNIQUE-JS-NAMES ...)

Macroexpansion:
(with-ps-gensyms 'some-name)
Write a Common Lisp macro to handle this code pattern:
(with* nil
  (progn))

Problem: Macro call that should be transformed by WITH*

Macro definition:
(defmacro WITH* ...)

Macroexpansion:
(progn)
Generate a defmacro form that transforms code like this:
(dlet nil
  (progn))

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

Macro definition:
(defmacro DLET ...)

Macroexpansion:
(dynamic-let nil
  (progn))
Create a Common Lisp macro for the following transformation. Before code:
(with-html-string (:html (:head) (:body (:a "hai"))))

What needs to change: 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 (:html (:head) (:body (:a "hai")))))
Generate a defmacro form that transforms code like this:
(with-attributes nil
    (progn))

Pattern to recognize: Macro call that should be transformed by WITH-ATTRIBUTES

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

Macroexpansion:
(let ((#:unit161 (progn)))
  (symbol-macrolet ()))
Write a Common Lisp macro to handle this code pattern:
(make-name-transformer \"FOO-\" name \"-BAR\") Use the slot name directly: :accessor-name-transformer (make-name-transformer name)" `(lambda (name definition) (declare (ignorable definition)) (concatenate-symbol ,@(mapcar (lambda (el) (if (and (symbolp el) (string= (symbol-name el) "NAME")) 'name el)) elements))))

Problem: Macro call that should be transformed by make-name-transformer

Macro definition:
(defmacro make-name-transformer (&rest elements)
  "Return an accessor name transformer.
The unquoted `name' symbol argument is substituted for the slot name.
Class option examples:

  :accessor-name-transformer (make-name-transformer \"FOO-\" name \"-BAR\")

Use the slot name directly:

  :accessor-name-transformer (make-name-transformer name)"
  `(lambda (name definition)
    (declare (ignorable definition))
    (concatenate-symbol ,@(mapcar (lambda (el)
                                    (if (and (symbolp el)
                                             (string= (symbol-name el) "NAME"))
                                        'name
                                        el))
                                  elements))))

Macroexpansion:
(lambda (name definition) (declare (ignorable definition)) (concatenate-symbol |"FOO-"| name |"-BAR"|))
Generate a defmacro form that transforms code like this:
(aif 1 (sif it it))

Pattern to recognize: 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 1 (sif it it) nil)
Define a macro that eliminates this repetitive pattern:
(define-dispatch dispatch-for-no-result (args specific-hooks) (mapc (lambda (f) (apply f args)) specific-hooks))

Issue: Macro call that should be transformed by define-dispatch

Macro definition:
(defmacro define-dispatch (name lambda-list &body body)
  "the lambda list should accept two arguments:
the list of arguments given by the current method call.
the specific hooks (as named or unamed functions) for the qualified method (that we will be dispatching from).

you should then use the arguments to dispatch the specific hooks as you wish in the body.
if the body returns a result, by default the method will also return that result, this can be overriden with finalize-dispatch-method.

See finalize-dispatch-method
See dispatch"
  `(let ((new-dispatch (make-dispatcher (lambda ,lambda-list ,@body))))
     (setf (gethash ',name *dispatch-table*)
           new-dispatch)))

Macroexpansion:
(let ((new-dispatch (make-dispatcher (lambda (args specific-hooks) (mapc (lambda (f) (apply f args)) specific-hooks))))) (setf (gethash (quote dispatch-for-no-result) *dispatch-table*) new-dispatch))
Define a macro that eliminates this repetitive pattern:
(true 4)

Issue: Macro call that should be transformed by true

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

Macroexpansion:
(eval-in-context *context* (make-instance (quote comparison-result) :expression (quote (true 4)) :value-form (quote 4) :body (lambda nil 4) :expected (quote t) :comparison (quote geq)))
Generate a defmacro form that transforms code like this:
(finalize-savepoint :rolled-back (call-next-method conn identifier))

Pattern to recognize: Macro call that should be transformed by finalize-savepoint

Macro definition:
(defmacro finalize-savepoint (new-state &body body)
  `(let ((state (get-transaction-state conn)))
     (unless (typep state 'savepoint-state)
       (error "Please, use release-savepoint inside of with-savepoint block."))
     (unless (equal (get-identifier state)
                    identifier)
       ;; TODO: probably optional `identifier' parameter
       ;;       is excessive and should be removed?
       (error "Identifier mismatch"))

     (multiple-value-prog1
         (progn ,@body)
       (setf (get-state state)
             ,new-state))))

Macroexpansion:
(let ((state (get-transaction-state conn))) (unless (typep state (quote savepoint-state)) (error "Please, use release-savepoint inside of with-savepoint block.")) (unless (equal (get-identifier state) identifier) (error "Identifier mismatch")) (multiple-value-prog1 (progn (call-next-method conn identifier)) (setf (get-state state) :rolled-back)))
Write a Common Lisp macro to handle this code pattern:
(builder (when t `(:sample :out ,(lambda (out) (format t "Got: ~a" out)))) *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 (let ((#:res183 (when t (sb-int:quasiquote (:sample :out #S(sb-impl::comma :expr (lambda (out) (format t "Got: ~a" out)) :kind 0)))))) (typecase #:res183 (keyword (find-middleware #:res183)) (cons (if (keywordp (car #:res183)) (let ((#:res-mw182 (find-middleware (car #:res183)))) (lambda (#:app181) (apply #:res-mw182 #:app181 (cdr #:res183)))) #:res183)) (standard-object (lambda (#:app181) (funcall (intern (string :wrap) :clack.middleware) #:res183 #:app181))) (otherwise #:res183))))) :initial-value (to-app *app*) :from-end t)
Define a macro that eliminates this repetitive pattern:
(define-error unknown-variable-type () (name) "Could not establish the type of the variable: ~s" name)

Issue: 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 unknown-variable-type (:error-type varjo-error :prefix "Varjo") (name) "Could not establish the type of the variable: ~s" name)
Write a Common Lisp macro to handle this code pattern:
(aggregate-scope-progv *array-scope-variables* (aggregate-scope-progv *aggregate-scope-variables* (funcall *beginning-of-array-handler*) (multiple-value-bind (type token) (peek-json-token stream) (if (and (eql type :punct) (char= token #\])) (progn (read-json-token stream) (return-from decode-json-array (funcall *end-of-array-handler*))) (funcall *array-member-handler* (funcall *internal-decoder* stream)))) (loop (multiple-value-bind (type token) (read-json-token stream) (if (eql type :punct) (case token (#\] (return-from decode-json-array (funcall *end-of-array-handler*))) (#\, (setq token nil)))) (if token (json-syntax-error stream "Token out of place in Array on JSON input: `~A'" token))) (funcall *array-member-handler* (funcall *internal-decoder* stream)))))

Problem: Macro call that should be transformed by aggregate-scope-progv

Macro definition:
(defmacro aggregate-scope-progv (variables &body body)
  "Establish a dynamic environment where all VARIABLES are freshly
bound (to their current values), and execute BODY in it, returning the
result."
  `(progv ,variables (mapcar #'symbol-value ,variables)
     ,@body))

Macroexpansion:
(progv *array-scope-variables* (mapcar (function symbol-value) *array-scope-variables*) (aggregate-scope-progv *aggregate-scope-variables* (funcall *beginning-of-array-handler*) (multiple-value-bind (type token) (peek-json-token stream) (if (and (eql type :punct) (char= token #\RIGHT_SQUARE_BRACKET)) (progn (read-json-token stream) (return-from decode-json-array (funcall *end-of-array-handler*))) (funcall *array-member-handler* (funcall *internal-decoder* stream)))) (loop (multiple-value-bind (type token) (read-json-token stream) (if (eql type :punct) (case token (#\RIGHT_SQUARE_BRACKET (return-from decode-json-array (funcall *end-of-array-handler*))) (#\COMMA (setq token nil)))) (if token (json-syntax-error stream "Token out of place in Array on JSON input: `~A'" token))) (funcall *array-member-handler* (funcall *internal-decoder* stream)))))
Define a macro that eliminates this repetitive pattern:
(builder (when t :sample) *app*)

Issue: 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 (let ((#:res180 (when t :sample))) (typecase #:res180 (keyword (find-middleware #:res180)) (cons (if (keywordp (car #:res180)) (let ((#:res-mw179 (find-middleware (car #:res180)))) (lambda (#:app178) (apply #:res-mw179 #:app178 (cdr #:res180)))) #:res180)) (standard-object (lambda (#:app178) (funcall (intern (string :wrap) :clack.middleware) #:res180 #:app178))) (otherwise #:res180))))) :initial-value (to-app *app*) :from-end t)
Define a macro that eliminates this repetitive pattern:
(send nil nil)

Issue: Macro call that should be transformed by SEND

Macro definition:
(defmacro SEND ...)

Macroexpansion:
(send (slot-value nil 'nil))
Generate a defmacro form that transforms code like this:
(defrule nil
  nil)

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

Macro definition:
(defmacro DEFRULE ...)

Macroexpansion:
(setf (gethash #A((3) base-char . "NIL") cl-rules.core::*rules*)
        '#S(cl-rules.core::rule
            :name #A((3) base-char . "NIL")
            :conditions (#S(cl-rules.core::condn
                            :name #A((3) base-char . "NIL")
                            :args nil))
            :actions nil))
Write a Common Lisp macro to handle this code pattern:
(define TMP_MAX 1024)

Problem: Macro call that should be transformed by define

Macro definition:
(defmacro define (name value &rest docstring)
  "Like a #define but also visible to Lisp code."
  `(progn
     (eval-when (:compile-toplevel :load-toplevel :execute)
       (defvar ,(pp-defines *package*) (make-hash-table))
       (setf (gethash ',name ,(pp-defines *package*)) ,(prin1-to-string value)))
     (defparameter ,name ,value ,@docstring)))

Macroexpansion:
(progn (eval-when (:compile-toplevel :load-toplevel :execute) (defvar *preprocessor-defines* (make-hash-table)) (setf (gethash (quote tmp_max) *preprocessor-defines*) #A((4) base-char . "1024"))) (defparameter tmp_max 1024))
Write a Common Lisp macro to handle this code pattern:
(define-definition-resolver transform (designator package) (let ((fun-info (when (symbolp designator) (sb-int:info :function :info designator)))) (when fun-info (loop for transform in (sb-c::fun-info-transforms fun-info) collect (make-instance 'transform :designator designator :package package :transform transform)))))

Problem: Macro call that should be transformed by define-definition-resolver

Macro definition:
(defmacro define-definition-resolver (name args &body body)
  `(progn (setf (definition-resolver ',name)
                (lambda ,args ,@body))
          ',name))

Macroexpansion:
(progn (setf (definition-resolver (quote transform)) (lambda (designator package) (let ((fun-info (when (symbolp designator) (sb-int:info :function :info designator)))) (when fun-info (loop for transform in (sb-c::fun-info-transforms fun-info) collect (make-instance (quote transform) :designator designator :package package :transform transform)))))) (quote transform))
Create a Common Lisp macro for the following transformation. Before code:
(collect nil nil)

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

Macro definition:
(defmacro COLLECT ...)

Macroexpansion:
(common-lisp:let* ((#:generator-591 (generator nil))
                   #:items-584
                   #:seq-585
                   (#:limit-586
                    (common-lisp:multiple-value-bind (x y)
                        (decode-seq-type (list 'quote nil))
                      (declare (ignore x))
                      y))
                   (#:lst-587 nil))
  (declare (type generator #:generator-591)
           (type (null-or nonnegative-integer) #:limit-586)
           (type list #:lst-587))
  (tagbody
   #:ll-592
    (setq #:items-584 (next-in #:generator-591 (go end)))
    (setq #:lst-587 (cons #:items-584 #:lst-587))
    (go #:ll-592)
   end)
  (common-lisp:let ((num (length #:lst-587)))
    (declare (type nonnegative-integer num))
    (setq #:seq-585 (make-sequence nil (or #:limit-586 num)))
    (do ((i (1- num) (1- i)))
        ((minusp i))
      (setf (elt #:seq-585 i) (pop #:lst-587))))
  #:seq-585)
Generate a defmacro form that transforms code like this:
(with-mapping-collector 'some-name)

Pattern to recognize: Macro call that should be transformed by WITH-MAPPING-COLLECTOR

Macro definition:
(defmacro WITH-MAPPING-COLLECTOR ...)

Macroexpansion:
(let ((#:col125 (make-collector)))
  (map-aggregation (#:col125 (lambda some-name))
    (flet ((quote (&rest #:flet-args126) (apply #:col125 #:flet-args126))))))
Create a Common Lisp macro for the following transformation. Before code:
(none-of 'some-name)

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

Macro definition:
(defmacro NONE-OF ...)

Macroexpansion:
(lc ('some-name) never)
Define a macro that eliminates this repetitive pattern:
(with-reducer 'some-name)

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

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

Macroexpansion:
(let ((#:reducer128
       (make-reducer some-name :initial-value (or nil nil) :place-setter nil)))
  (flet ((quote (&rest items) (apply #:reducer128 items)))))
You are a Common Lisp macro expert. Given this code pattern:
(integer-writer 2)

Write a macro that addresses: Macro call that should be transformed by integer-writer

Macro definition:
(defmacro integer-writer (bytes)
  "Create a function to write integers to a binary stream."
  (let ((bits (* 8 bytes)))
    `(progn
       (declaim (inline ,(integer-writer-name bytes t)
                        ,(integer-writer-name bytes nil)))
       (defun ,(integer-writer-name bytes nil) (socket value)
         (declare (type stream socket)
                  (type (unsigned-byte ,bits) value)
                  #.*optimize*)
         ,@(if (= bytes 1)
               `((write-byte value socket))
               (loop :for byte :from (1- bytes) :downto 0
                     :collect `(write-byte (ldb (byte 8 ,(* byte 8)) value)
                                           socket)))
         (values))
       (defun ,(integer-writer-name bytes t) (socket value)
         (declare (type stream socket)
                  (type (signed-byte ,bits) value)
                  #.*optimize*)
         ,@(if (= bytes 1)
               `((write-byte (ldb (byte 8 0) value) socket))
               (loop :for byte :from (1- bytes) :downto 0
                     :collect `(write-byte (ldb (byte 8 ,(* byte 8)) value)
                                           socket)))
         (values)))))

Macroexpansion:
(progn (declaim (inline write-int2 write-uint2)) (defun write-uint2 (socket value) (declare (type stream socket) (type (unsigned-byte 16) value) (optimize (speed 3) (safety 0) (space 1) (debug 1) (compilation-speed 0))) (write-byte (ldb (byte 8 8) value) socket) (write-byte (ldb (byte 8 0) value) socket) (values)) (defun write-int2 (socket value) (declare (type stream socket) (type (signed-byte 16) value) (optimize (speed 3) (safety 0) (space 1) (debug 1) (compilation-speed 0))) (write-byte (ldb (byte 8 8) value) socket) (write-byte (ldb (byte 8 0) value) socket) (values)))
You are a Common Lisp macro expert. Given this code pattern:
(with-reader-case nil
  (progn))

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

Macro definition:
(defmacro WITH-READER-CASE ...)

Macroexpansion:
(let ()
  (let ((#:previous-case180 (readtable-case *readtable*)))
    (setf (readtable-case *readtable*) nil)
    (unwind-protect (progn (progn))
      (setf (readtable-case *readtable*) #:previous-case180))))
Define a macro that eliminates this repetitive pattern:
(def-neo4j-fun create-index ((type :node) name config) :post (:uri-spec (format nil "index/~A" (string-downcase (symbol-name type)))) (:encode (cons (cons :name name) config) :string) (:status-handlers (201 (decode-neo4j-json-output body))))

Issue: Macro call that should be transformed by def-neo4j-fun

Macro definition:
(defmacro def-neo4j-fun (name lambda-list method &rest args)
  `(progn
     (defun ,name (&key ,@lambda-list)
       (let ((uri ,(cadr (assoc :uri-spec args)))
             (json (encode-neo4j-json-payload ,@(aif (assoc :encode args)
                                                     (cdr it)
                                                     (list '() :string)))))
         (make-neo4j-request ,method uri json
                             (list ,@(mapcar (lambda (handler)
                                               `(list ,(car handler) (lambda (body uri json)
                                                                  ,(cadr handler))))
                                             (cdr (assoc :status-handlers args)))))))))

Macroexpansion:
(progn (defun create-index (&key (type :node) name config) (let ((uri (format nil "index/~A" (string-downcase (symbol-name type)))) (json (encode-neo4j-json-payload (cons (cons :name name) config) :string))) (make-neo4j-request :post uri json (list (list 201 (lambda (body uri json) (decode-neo4j-json-output body))))))))
Generate a defmacro form that transforms code like this:
(defstruct-compile-time function-record function-name (lambda-list nil) (body nil) (callees nil) (deterministic? t) (old-deterministic? nil) (screamer? *screamer?*))

Pattern to recognize: Macro call that should be transformed by defstruct-compile-time

Macro definition:
(defmacro defstruct-compile-time (options &body items)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (defstruct ,options ,@items)))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (defstruct function-record function-name (lambda-list nil) (body nil) (callees nil) (deterministic? t) (old-deterministic? nil) (screamer? *screamer?*)))
You are a Common Lisp macro expert. Given this code pattern:
(define-alias-binding update updating)

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

Macro definition:
(defmacro define-alias-binding (name referenced-binding-name)
  `(progn (setf (binding ',name) ',referenced-binding-name)
          ',name))

Macroexpansion:
(progn (setf (binding (quote update)) (quote updating)) (quote update))
Create a Common Lisp macro for the following transformation. Before code:
(declare-deprecated-operators nil (progn))

What needs to change: Macro call that should be transformed by DECLARE-DEPRECATED-OPERATORS

Macro definition:
(defmacro DECLARE-DEPRECATED-OPERATORS ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (define-compiler-macro nil
      (&whole form &rest arguments)
    (declare (ignore arguments))
    (let ((where-from (or *compile-file-truename* *load-truename*)))
      (when *deprecation-warnings*
        (warn 'deprecation-warning :operator-name 'nil :source-file where-from
              :source-form form))
      (when where-from
        (pushnew where-from (gethash 'nil *deprecation-locations*) :test
                 #'equalp))
      form))
  (define-compiler-macro (progn)
      (&whole form &rest arguments)
    (declare (ignore arguments))
    (let ((where-from (or *compile-file-truename* *load-truename*)))
      (when *deprecation-warnings*
        (warn 'deprecation-warning :operator-name '(progn) :source-file
              where-from :source-form form))
      (when where-from
        (pushnew where-from (gethash '(progn) *deprecation-locations*) :test
                 #'equalp))
      form))
  (values))
Write a Common Lisp macro to handle this code pattern:
(loop-on-custom (key var value) customizations collect (list var value))

Problem: Macro call that should be transformed by loop-on-custom

Macro definition:
(defmacro loop-on-custom ((key var &optional value) &rest clauses)
  (if value
      (destructuring-bind (key-args . clauses) clauses
        `(loop for (,key ,value) on ,key-args by #'cddr
            for ,var = (custom-key-to-variable ,key)
            if ,var ,@clauses))
      `(loop for (,var . ,key) in *custom-vars*
            ,@clauses)))

Macroexpansion:
(loop for (key value) on customizations by (function cddr) for var = (custom-key-to-variable key) if var collect (list var value))
Write a Common Lisp macro to handle this code pattern:
(define-error not-core-type-error () (type-name) "Type ~a is not a core type and thus cannot end up in glsl src code It must end up being used or converted to something that resolves to a glsl type." type-name)

Problem: 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 not-core-type-error (:error-type varjo-error :prefix "Varjo") (type-name) "Type ~a is not a core type and thus cannot end up in glsl src code It must end up being used or converted to something that resolves to a glsl type." type-name)
You are a Common Lisp macro expert. Given this code pattern:
(send 'some-name)

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

Macro definition:
(defmacro SEND ...)

Macroexpansion:
'some-name