j14i/cl-macros huggingface dataset:
Create a Common Lisp macro for the following transformation. Before code:
(do-generator (a b (izip-longest (list->generator data) (some-numbers) :fill-value 10)) (incf x (* a b)))

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

Macro definition:
(defmacro do-generator ((var &rest vars-and-generator) &body body)
  "Steps through the specified generator, binding the value it returns to var, then executing the body for each step. If multiple variables are specified and the generator returns multiple values, the extra values will be bound to the extra variables."
  (let ((g (gensym)))
    `(let ((,g ,(car (last vars-and-generator))))
       (loop 
	  do (if-generator ((,var ,@(butlast vars-and-generator)) ,g)
			   (progn
			     ,@body)
			   (return))))))

Macroexpansion:
(let ((#:g178 (izip-longest (list->generator data) (some-numbers) :fill-value 10))) (loop do (if-generator ((a b) #:g178) (progn (incf x (* a b))) (return))))
Create a Common Lisp macro for the following transformation. Before code:
(defsynonym terminate :terminate)

What needs to change: 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 terminate) (quote synonym)) (quote :terminate)))
Define a macro that eliminates this repetitive pattern:
(with-mocks () (values 1 2 3))

Issue: Macro call that should be transformed by with-mocks

Macro definition:
(defmacro with-mocks ((&key (recordp T)) &body body)
  "Execute BODY in a new mocking context.  Invocations will be recorded
if RECORDP is set (default true)."
  `(call-with-mocks
    (lambda () ,@body)
    :recordp ,recordp))

Macroexpansion:
(call-with-mocks (lambda nil (values 1 2 3)) :recordp t)
Create a Common Lisp macro for the following transformation. Before code:
(cond->
  nil
  (progn))

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

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

Macroexpansion:
(let* ((#:var129 nil)
       (#:var130
        (if progn
            (->
              #:var129)
            #:var129)))
  #:var130)
Define a macro that eliminates this repetitive pattern:
(m nil)

Issue: Macro call that should be transformed by M

Macro definition:
(defmacro M ...)

Macroexpansion:
(lambda (&rest #:|macro-lambda-list120|)
  (destructuring-bind () #:|macro-lambda-list120|))
Define a macro that eliminates this repetitive pattern:
(psetf nil (progn))

Issue: Macro call that should be transformed by PSETF

Macro definition:
(defmacro PSETF ...)

Macroexpansion:
(progn (setf nil (progn)) nil)
Generate a defmacro form that transforms code like this:
(with-unique-js-names nil (progn))

Pattern to recognize: Macro call that should be transformed by WITH-UNIQUE-JS-NAMES

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

Macroexpansion:
(with-ps-gensyms nil
  (progn))
Write a Common Lisp macro to handle this code pattern:
(define-column-type bigserial () '(:bigint 20 :unsigned))

Problem: Macro call that should be transformed by define-column-type

Macro definition:
(defmacro define-column-type (type-symbol lambda-list &body body)
  (let ((type (gensym "TYPE"))
        (args (gensym "ARGS")))
    `(defmethod cltype-to-dbtype ((,type (eql ',type-symbol)) &rest ,args)
       (declare (ignore ,type))
       (destructuring-bind ,lambda-list ,args
         ,@body))))

Macroexpansion:
(defmethod cltype-to-dbtype ((#:type226 (eql (quote bigserial))) &rest #:args227) (declare (ignore #:type226)) (destructuring-bind nil #:args227 (quote (:bigint 20 :unsigned))))
Define a macro that eliminates this repetitive pattern:
(mapcar (lambda (f) (apply 'dump-fbinding f)) bindings)

Issue: Macro call that should be transformed by m

Macro definition:
(defmacro m (form &environment *env*)
  (e form))

Macroexpansion:
(mapcar (lambda (f) (apply (quote dump-fbinding) f)) bindings)
Generate a defmacro form that transforms code like this:
(augment *decls* decls)

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

Macro definition:
(defmacro augment (var stuff)
  `(setf ,var (nconc ,var ,stuff)))

Macroexpansion:
(setf *decls* (nconc *decls* decls))
Write a Common Lisp macro to handle this code pattern:
(with-standard-definer-options nil
  (progn))

Problem: Macro call that should be transformed by WITH-STANDARD-DEFINER-OPTIONS

Macro definition:
(defmacro WITH-STANDARD-DEFINER-OPTIONS ...)

Macroexpansion:
`(progn
  ,@(when (getf -options- :export)
      `((eval-when (:compile-toplevel :load-toplevel :execute)
          (export ',nil))))
  ,(progn))
Generate a defmacro form that transforms code like this:
(do+ (for x (in-list ())) (collect x))

Pattern to recognize: 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 (in-list nil)) (collect x))
Create a Common Lisp macro for the following transformation. Before code:
(define-global-var* nil (progn))

What needs to change: Macro call that should be transformed by DEFINE-GLOBAL-VAR*

Macro definition:
(defmacro DEFINE-GLOBAL-VAR* ...)

Macroexpansion:
(sb-ext:define-load-time-global nil (progn))
Generate a defmacro form that transforms code like this:
(if-let (x (opaque :ok)) x :bad)

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 (opaque :ok))) (if (and x) x :bad))
Create a Common Lisp macro for the following transformation. Before code:
(the-part nil)

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

Macro definition:
(defmacro THE-PART ...)

Macroexpansion:
(send part nil)
Define a macro that eliminates this repetitive pattern:
(skipped-tests (remove-if-not #'test-skipped-p result-list))

Issue: Macro call that should be transformed by skip

Macro definition:
(defmacro skip (&rest reason)
  "Generates a TEST-SKIPPED result."
  `(add-result 'test-skipped :reason (format nil ,@reason)))

Macroexpansion:
(skipped-tests (remove-if-not (function test-skipped-p) result-list))
Write a Common Lisp macro to handle this code pattern:
(scase (car x) (0 (setf it :no)) (3 (setf it :yes!)) (t (setf it :nono)))

Problem: Macro call that should be transformed by scase

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

Macroexpansion:
(symbolic case (car x) (0 (setf it :no)) (3 (setf it :yes!)) (t (setf it :nono)))
Generate a defmacro form that transforms code like this:
(when (eq (slot-value item slot) nil) (setf subnodes (remove slot subnodes)))

Pattern to recognize: 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 (eq (slot-value item slot) nil) (setf subnodes (remove slot subnodes)))
Define a macro that eliminates this repetitive pattern:
(failed-tests (remove-if-not #'test-failure-p result-list))

Issue: Macro call that should be transformed by fail

Macro definition:
(defmacro fail (&rest message-args)
  "Simply generate a FAIL."
  `(process-failure ',message-args
                    ,@message-args))

Macroexpansion:
(failed-tests (remove-if-not (function test-failure-p) result-list))
Define a macro that eliminates this repetitive pattern:
(defclass test-class2 (test-parent) ((c :accessor c-of :initarg :c)))

Issue: Macro call that should be transformed by defclass

Macro definition:
(defmacro defclass (name direct-superclasses direct-slots &rest options)
  "Define Modf expansions for class slot accessor and reader methods."
  ;; We need the names of all methods that access data in the object and what
  ;; slot they are associated with.
  `(progn
     (cl:defclass ,name ,direct-superclasses ,direct-slots ,@options)
     ,@(iter :outer
         (for slot in direct-slots)
         (let ((slot-name (if (atom slot) slot (first slot))))
           (iter (for accessor in (remove-if-not
                                   (lambda (x) (member
                                           (first x)
                                           '(:accessor :reader)))
                                   (group-by (rest slot) 2)))
             (in :outer
                 (collecting
                  `(define-modf-method ,(second accessor) 1
                       (new-val (obj ,name))
                     (modf (slot-value obj ',slot-name) new-val)))))))))

Macroexpansion:
(progn (eval-when (:compile-toplevel) (sb-kernel::%compiler-defclass (quote test-class2) (quote (c-of)) (quote ((setf c-of))) (quote (c)))) (let nil (sb-pcl::load-defclass (quote test-class2) (quote standard-class) (quote (test-parent)) (list (list* :name (quote c) :readers (quote (c-of)) :writers (quote ((setf c-of))) :initargs (quote (:c)) (quote sb-pcl::source) #S(sb-c:definition-source-location :namestring nil :indices 0) (quote nil))) (list :direct-default-initargs nil) (quote (c-of)) (quote ((setf c-of))) (quote (c)) (sb-c:source-location))))
You are a Common Lisp macro expert. Given this code pattern:
(loop-on-custom (key var) do (collect key var))

Write a macro that addresses: 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 (var . key) in *custom-vars* do (collect key var))
Create a Common Lisp macro for the following transformation. Before code:
(check-cursor-attached cluffer:join-line (cursor))

What needs to change: Macro call that should be transformed by check-cursor-attached

Macro definition:
(defmacro check-cursor-attached (name arguments)
  (let ((args (substitute '(cursor cluffer:cursor) 'cursor arguments)))
    `(defmethod ,name :before ,args
       (declare (ignore ,@(set-difference (remove 'cursor arguments)
                                          lambda-list-keywords)))
       (unless (cluffer:cursor-attached-p cursor)
         (error 'cluffer:cursor-detached)))))

Macroexpansion:
(defmethod cluffer:join-line :before ((cursor cluffer:cursor)) (declare (ignore)) (unless (cluffer:cursor-attached-p cursor) (error (quote cluffer:cursor-detached))))
Define a macro that eliminates this repetitive pattern:
(with-preprocessor-state-slots (state) (let ((i-state (make-instance 'saved-include-state :if-section-stack if-section-stack :package *package* :readtable *readtable*))) (push i-state include-stack)))

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 (let ((i-state (make-instance (quote saved-include-state) :if-section-stack if-section-stack :package *package* :readtable *readtable*))) (push i-state include-stack)))
Define a macro that eliminates this repetitive pattern:
(-> :g () (put 3) (mt:open-latch latch))

Issue: Macro call that should be transformed by ->

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

Macroexpansion:
(atomically :g nil (put 3) (cl-muth:open-latch latch))
Define a macro that eliminates this repetitive pattern:
(%define-hash-table-entries-pattern hash-table-entries! hash-table-entry!)

Issue: Macro call that should be transformed by %define-hash-table-entries-pattern

Macro definition:
(defmacro %define-hash-table-entries-pattern (name entry-pattern)
  `(defpattern ,name (key pattern &rest keys-and-patterns)
    ,(format nil "Matches hash table which has KEY set to value matching PATTERN.~
                  Multiple KEY PATTERN pairs can be provided, e.g. `(~A :key1 _ :key2 value :key3 1)`.~
                  Expands into list of ~A patterns combined with AND."
             name entry-pattern)
    (when (oddp (length keys-and-patterns))
      (warn 'hash-table-odd-number-of-entries-warning
            :format-control ,(format nil "Odd number of arguments given to ~A pattern. NIL will be used as ~~S pattern." name)
            :format-arguments (last keys-and-patterns)))
    `(and ,(list ',entry-pattern key pattern)
          ,@(loop :for (key pattern) :on keys-and-patterns :by #'cddr
                  :collect (list ',entry-pattern key pattern)))))

Macroexpansion:
(defpattern hash-table-entries! (key pattern &rest keys-and-patterns) #A((230) base-char . "Matches hash table which has KEY set to value matching PATTERN.Multiple KEY PATTERN pairs can be provided, e.g. `(HASH-TABLE-ENTRIES! :key1 _ :key2 value :key3 1)`.Expands into list of HASH-TABLE-ENTRY! patterns combined with AND.") (when (oddp (length keys-and-patterns)) (warn (quote hash-table-odd-number-of-entries-warning) :format-control #A((93) base-char . "Odd number of arguments given to HASH-TABLE-ENTRIES! pattern. NIL will be used as ~S pattern.") :format-arguments (last keys-and-patterns))) (sb-int:quasiquote (and #S(sb-impl::comma :expr (list (quote hash-table-entry!) key pattern) :kind 0) #S(sb-impl::comma :expr (loop :for (key pattern) :on keys-and-patterns :by (function cddr) :collect (list (quote hash-table-entry!) key pattern)) :kind 2))))
Create a Common Lisp macro for the following transformation. Before code:
(dynamic-progv nil
    :key
  nil)

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

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

Macroexpansion:
(let* ((#:fixed-symbols241 nil)
       (#:fixed-bindings242 (compute-bindings #:fixed-symbols241 :key)))
  (dynamic-wind
    :proceed
    #:proceed243
    (progv #:fixed-symbols241 #:fixed-bindings242 (#:proceed243 nil))))
Define a macro that eliminates this repetitive pattern:
(product-of nil)

Issue: Macro call that should be transformed by PRODUCT-OF

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

Macroexpansion:
(lc (nil) multiply)
You are a Common Lisp macro expert. Given this code pattern:
(collect-ignore 'some-name)

Write a macro that addresses: Macro call that should be transformed by COLLECT-IGNORE

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

Macroexpansion:
(common-lisp:let* ((#:generator-174 (generator 'some-name)))
  (declare (type generator #:generator-174))
  (tagbody #:ll-175 (next-in #:generator-174 (go end)) (go #:ll-175) end)
  nil)
Generate a defmacro form that transforms code like this:
(with-color (:green :stream stream) (with-additional-indent (reporter stream "✓ ") (let ((description (possible-report-description report)) (duration (slot-value report 'duration))) (when description (with-color (:gray :stream stream) (format/indent reporter stream description))) (when duration (format stream " ") (print-duration stream duration (slot-value report 'slow-threshold)))) (terpri stream)))

Pattern to recognize: Macro call that should be transformed by with-color

Macro definition:
(defmacro with-color ((color &rest args) &body body)
  (cond
    ((or (eq color :gray)
         (eq color :grey))
     `(if *enable-colors*
          (with-gray ,(or (getf args :stream) t) ,@body)
          (progn ,@body)))
    (T `(if *enable-colors*
            (if (or (eq ,color :gray)
                    (eq ,color :grey)
                    (eq ,color cl-colors:+gray+)
                    (eq ,color cl-colors:+grey+))
                (with-gray ,(or (getf args :stream) t) ,@body)
                (cl-ansi-text:with-color (,color ,@args) ,@body))
            (progn ,@body)))))

Macroexpansion:
(if *enable-colors* (if (or (eq :green :gray) (eq :green :grey) (eq :green +gray+) (eq :green +grey+)) (with-gray stream (with-additional-indent (reporter stream "✓ ") (let ((description (possible-report-description report)) (duration (slot-value report (quote duration)))) (when description (with-color (:gray :stream stream) (format/indent reporter stream description))) (when duration (format stream " ") (print-duration stream duration (slot-value report (quote slow-threshold))))) (terpri stream))) (cl-ansi-text:with-color (:green :stream stream) (with-additional-indent (reporter stream "✓ ") (let ((description (possible-report-description report)) (duration (slot-value report (quote duration)))) (when description (with-color (:gray :stream stream) (format/indent reporter stream description))) (when duration (format stream " ") (print-duration stream duration (slot-value report (quote slow-threshold))))) (terpri stream)))) (progn (with-additional-indent (reporter stream "✓ ") (let ((description (possible-report-description report)) (duration (slot-value report (quote duration)))) (when description (with-color (:gray :stream stream) (format/indent reporter stream description))) (when duration (format stream " ") (print-duration stream duration (slot-value report (quote slow-threshold))))) (terpri stream))))
Generate a defmacro form that transforms code like this:
(define-case-aware-token-p-function pp-once-pragma-p find-pragma-name with-c-syntax.pragma-name:|once|)

Pattern to recognize: Macro call that should be transformed by define-case-aware-token-p-function

Macro definition:
(defmacro define-case-aware-token-p-function (function-name find-symbol-function symbol)
  `(defun ,function-name (token &optional (readtable-case (readtable-case *readtable*)))
     (and (symbolp token)
          (eq (,find-symbol-function (string token) readtable-case)
              ',symbol))))

Macroexpansion:
(defun pp-once-pragma-p (token &optional (readtable-case (readtable-case *readtable*))) (and (symbolp token) (eq (find-pragma-name (string token) readtable-case) (quote with-c-syntax.pragma-name:|once|))))
Write a Common Lisp macro to handle this code pattern:
(true 3)

Problem: 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 3)) :value-form (quote 3) :body (lambda nil 3) :expected (quote t) :comparison (quote geq)))
Generate a defmacro form that transforms code like this:
(escaped-char-dispatch c :code-handler ((len rdx) (let ((code (let ((repr (make-string len))) (dotimes (i len) (setf (aref repr i) (read-char stream))) (handler-case (parse-integer repr :radix rdx) (parse-error () (json-syntax-error stream esc-error-fmt (format nil "\\~C" c) repr)))))) (restart-case (or (and (< code char-code-limit) (code-char code)) (error 'no-char-for-code :code code)) (substitute-char (char) :report "Substitute another char." :interactive (lambda () (format *query-io* "Char: ") (list (read-char *query-io*))) char) (pass-code () :report "Pass the code to char handler." code)))) :default-handler (if *use-strict-json-rules* (json-syntax-error stream esc-error-fmt "\\" c) c))

Pattern to recognize: Macro call that should be transformed by escaped-char-dispatch

Macro definition:
(defmacro escaped-char-dispatch (char &key code-handler default-handler)
  "Compiles the escaped character alist to a (CASE ...) match expression."
  `(case ,char
     ,@(loop for (c . unescaped) in +json-lisp-escaped-chars+
          if (characterp unescaped)
            collect (list c unescaped)
          else if (consp unescaped)
            collect
              (destructuring-bind ((len rdx) &body body) code-handler
                (destructuring-bind (len-v . rdx-v) unescaped
                  `(,c (let ((,len ,len-v) (,rdx ,rdx-v)) ,@body)))))
     (t ,default-handler)))

Macroexpansion:
(case c (#\QUOTATION_MARK #\QUOTATION_MARK) (#\REVERSE_SOLIDUS #\REVERSE_SOLIDUS) (#\SOLIDUS #\SOLIDUS) (#\LATIN_SMALL_LETTER_B #\Backspace) (#\LATIN_SMALL_LETTER_F #\Page) (#\LATIN_SMALL_LETTER_N #\Newline) (#\LATIN_SMALL_LETTER_R #\Return) (#\LATIN_SMALL_LETTER_T #\Tab) (#\LATIN_SMALL_LETTER_U (let ((len 4) (rdx 16)) (let ((code (let ((repr (make-string len))) (dotimes (i len) (setf (aref repr i) (read-char stream))) (handler-case (parse-integer repr :radix rdx) (parse-error nil (json-syntax-error stream esc-error-fmt (format nil "\\~C" c) repr)))))) (restart-case (or (and (< code char-code-limit) (code-char code)) (error (quote no-char-for-code) :code code)) (substitute-char (char) :report "Substitute another char." :interactive (lambda nil (format *query-io* "Char: ") (list (read-char *query-io*))) char) (pass-code nil :report "Pass the code to char handler." code))))) (t (if *use-strict-json-rules* (json-syntax-error stream esc-error-fmt "\\" c) c)))