j14i/cl-macros huggingface dataset:
You are a Common Lisp macro expert. Given this code pattern:
(define-abstract-class nil :key nil)

Write a macro that addresses: Macro call that should be transformed by DEFINE-ABSTRACT-CLASS

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

Macroexpansion:
(defclass nil :key nil (:metaclass abstract-class))
Write a Common Lisp macro to handle this code pattern:
(augment finalp-code finalp)

Problem: Macro call that should be transformed by augment

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

Macroexpansion:
(setf finalp-code (nconc finalp-code finalp))
You are a Common Lisp macro expert. Given this code pattern:
(define-value-binding across (var vector &aux (i 0) (length (length vector))) (declare (type vector vector) (type (integer 0) i length)) `(cond ((= ,length ,i) (end-for)) (T (update ,var (aref ,vector ,i)) (incf ,i))))

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

Macro definition:
(defmacro define-value-binding (name (var &rest args) &body body)
  (let ((vars (lambda-fiddle:extract-lambda-vars (lambda-fiddle:remove-aux-part args))))
    (emit-binding-definition name var args body :extra-vars vars)))

Macroexpansion:
(define-direct-binding across (var vector) (let ((#:i141 (gensym #A((1) base-char . "I"))) (#:length142 (gensym #A((6) base-char . "LENGTH"))) (#:vector140 (gensym #A((6) base-char . "VECTOR")))) (values* (sb-int:quasiquote (with-interleaving (let* #S(sb-impl::comma :expr (list* (list #:vector140 vector) (list #:i141 0) (list #:length142 (list (quote length) #:vector140)) (loop for #:var139 in (lambda-fiddle:extract-lambda-vars (enlist var)) collect (list #:var139 nil))) :kind 0) (declare (ignorable #S(sb-impl::comma :expr #:i141 :kind 0) #S(sb-impl::comma :expr #:length142 :kind 0) #S(sb-impl::comma :expr #:vector140 :kind 0))) #S(sb-impl::comma :expr (sb-int:quasiquote (declare (type #S(sb-impl::comma :expr (quote vector) :kind 0) #S(sb-impl::comma :expr #:vector140 :kind 0)))) :kind 0) #S(sb-impl::comma :expr (sb-int:quasiquote (declare (type #S(sb-impl::comma :expr (quote (integer 0)) :kind 0) #S(sb-impl::comma :expr #:i141 :kind 0)))) :kind 0) #S(sb-impl::comma :expr (sb-int:quasiquote (declare (type #S(sb-impl::comma :expr (quote (integer 0)) :kind 0) #S(sb-impl::comma :expr #:length142 :kind 0)))) :kind 0)) #S(sb-impl::comma :expr nil :kind 0))) (let ((i #:i141) (length #:length142) (vector #:vector140)) (declare (ignorable i length vector)) (sb-int:quasiquote (cond ((= #S(sb-impl::comma :expr length :kind 0) #S(sb-impl::comma :expr i :kind 0)) (end-for)) (t (update #S(sb-impl::comma :expr var :kind 0) (aref #S(sb-impl::comma :expr vector :kind 0) #S(sb-impl::comma :expr i :kind 0))) (incf #S(sb-impl::comma :expr i :kind 0)))))))))
Write a Common Lisp macro to handle this code pattern:
(lambda-match ((list* :method args) (make-save-method args)) ((list* :method-combination name options) (setf combination name) (setf combination-options options)))

Problem: Macro call that should be transformed by lambda-match

Macro definition:
(defmacro lambda-match (&body clauses)
  (with-gensyms (args)
    `(lambda (,args)
       (match ,args
	 ,@clauses))))

Macroexpansion:
(lambda (#:args125) (match #:args125 ((list* :method args) (make-save-method args)) ((list* :method-combination name options) (setf combination name) (setf combination-options options))))
You are a Common Lisp macro expert. Given this code pattern:
(with-color (:red :stream stream) (with-additional-indent (reporter stream "× ") (let ((description (possible-report-description report)) (duration (slot-value report 'duration))) (when description (format/indent reporter stream description)) (when duration (format stream " ") (print-duration stream duration (slot-value report 'slow-threshold)))) (when (slot-value report 'description) (format/indent reporter stream (concatenate 'string "~&" (report-expected-line report))))) (terpri stream))

Write a macro that addresses: 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 :red :gray) (eq :red :grey) (eq :red +gray+) (eq :red +grey+)) (with-gray stream (with-additional-indent (reporter stream "× ") (let ((description (possible-report-description report)) (duration (slot-value report (quote duration)))) (when description (format/indent reporter stream description)) (when duration (format stream " ") (print-duration stream duration (slot-value report (quote slow-threshold))))) (when (slot-value report (quote description)) (format/indent reporter stream (concatenate (quote string) "~&" (report-expected-line report))))) (terpri stream)) (cl-ansi-text:with-color (:red :stream stream) (with-additional-indent (reporter stream "× ") (let ((description (possible-report-description report)) (duration (slot-value report (quote duration)))) (when description (format/indent reporter stream description)) (when duration (format stream " ") (print-duration stream duration (slot-value report (quote slow-threshold))))) (when (slot-value report (quote description)) (format/indent reporter stream (concatenate (quote string) "~&" (report-expected-line report))))) (terpri stream))) (progn (with-additional-indent (reporter stream "× ") (let ((description (possible-report-description report)) (duration (slot-value report (quote duration)))) (when description (format/indent reporter stream description)) (when duration (format stream " ") (print-duration stream duration (slot-value report (quote slow-threshold))))) (when (slot-value report (quote description)) (format/indent reporter stream (concatenate (quote string) "~&" (report-expected-line report))))) (terpri stream)))
Write a Common Lisp macro to handle this code pattern:
(path (gensym "path"))

Problem: Macro call that should be transformed by path

Macro definition:
(defmacro path (&body cmds)
  (let ((path (gensym "path")))
    `(let ((,path (make-path)))
       (with-path ,path
         ,@cmds)
       ,path)))

Macroexpansion:
(let ((#:|path140| (make-path))) (with-path #:|path140| (gensym "path")) #:|path140|)
You are a Common Lisp macro expert. Given this code pattern:
(dynamic-let* 'some-name)

Write a macro that addresses: Macro call that should be transformed by DYNAMIC-LET*

Macro definition:
(defmacro DYNAMIC-LET* ...)

Macroexpansion:
(dynamic-let (quote)
  (dynamic-let* (some-name)))
Write a Common Lisp macro to handle this code pattern:
(inext 'some-name)

Problem: Macro call that should be transformed by INEXT

Macro definition:
(defmacro INEXT ...)

Macroexpansion:
(let ((vals (multiple-value-list (funcall (i-coro 'some-name) nil))))
  (if (not vals)
      (coexit!)
      (car vals)))
Generate a defmacro form that transforms code like this:
(ps-html)

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

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

Macroexpansion:
(stringify)
You are a Common Lisp macro expert. Given this code pattern:
(with-yield-binds (format nil "~A~:[~; AFTER ~:*~A~]~:[~; FIRST~]" (call-next-method) (and (column-modifier-clause-after clause) (yield (column-modifier-clause-after clause))) (column-modifier-clause-first clause)))

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

Macro definition:
(defmacro with-yield-binds (&body body)
  `(let ((*bind-values* nil)
         (*use-global-bind-values* t))
     (values
      (progn ,@body)
      (loop for bind in (reverse *bind-values*)
            append bind))))

Macroexpansion:
(let ((*bind-values* nil) (*use-global-bind-values* t)) (values (progn (format nil "~A~:[~; AFTER ~:*~A~]~:[~; FIRST~]" (call-next-method) (and (column-modifier-clause-after clause) (yield (column-modifier-clause-after clause))) (column-modifier-clause-first clause))) (loop for bind in (reverse *bind-values*) append bind)))
You are a Common Lisp macro expert. Given this code pattern:
(with-unique-names (value coerced-value) `((,name (,value) (let ((,coerced-value (coerce ,value ',type))) (declare (type ,type ,coerced-value)) (when (or ,firstp (< ,coerced-value ,var)) (setq ,var ,coerced-value ,firstp nil))))))

Write a macro that addresses: 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"))) (coerced-value (gensym #A((14) base-char . "COERCED-VALUE-")))) (quasiquote ((#S(sb-impl::comma :expr name :kind 0) (#S(sb-impl::comma :expr value :kind 0)) (let ((#S(sb-impl::comma :expr coerced-value :kind 0) (coerce #S(sb-impl::comma :expr value :kind 0) (quote #S(sb-impl::comma :expr type :kind 0))))) (declare (type #S(sb-impl::comma :expr type :kind 0) #S(sb-impl::comma :expr coerced-value :kind 0))) (when (or #S(sb-impl::comma :expr firstp :kind 0) (< #S(sb-impl::comma :expr coerced-value :kind 0) #S(sb-impl::comma :expr var :kind 0))) (setq #S(sb-impl::comma :expr var :kind 0) #S(sb-impl::comma :expr coerced-value :kind 0) #S(sb-impl::comma :expr firstp :kind 0) nil)))))))
You are a Common Lisp macro expert. Given this code pattern:
(or)

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

Macro definition:
(defmacro OR ...)

Macroexpansion:
nil
Generate a defmacro form that transforms code like this:
(define-shell-component ditaa :input-type "ditaa" :output-type "png" :shell-command "ditaa")

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

Macro definition:
(defmacro define-shell-component (name &key input-type output-type shell-command)
  "Define an ASDF component that's compiled by running a shell command."
  `(define-component ,name
     :input-type ,input-type
     :output-type ,output-type
     :compile-function (lambda (input-pathname output-pathname)
                         (inferior-shell:run (list ,@(ensure-list shell-command)
                                                    input-pathname
                                                    output-pathname)
                                             :show t))))

Macroexpansion:
(define-component ditaa :input-type "ditaa" :output-type "png" :compile-function (lambda (input-pathname output-pathname) (inferior-shell:run (list "ditaa" input-pathname output-pathname) :show t)))
Generate a defmacro form that transforms code like this:
(signal-syntax-error* (+ open-paren-pos 2) "Opening paren has no matching closing paren.")

Pattern to recognize: Macro call that should be transformed by signal-syntax-error*

Macro definition:
(defmacro signal-syntax-error* (pos format-control &rest format-arguments)
  `(error 'ppcre-syntax-error
          :pos ,pos
          :format-control ,format-control
          :format-arguments (list ,@format-arguments)))

Macroexpansion:
(error (quote ppcre-syntax-error) :pos (+ open-paren-pos 2) :format-control "Opening paren has no matching closing paren." :format-arguments (list))
Create a Common Lisp macro for the following transformation. Before code:
(use-syntax nil)

What needs to change: Macro call that should be transformed by USE-SYNTAX

Macro definition:
(defmacro use-syntax (name)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (%use-syntax ,name)))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (%use-syntax nil))
Write a Common Lisp macro to handle this code pattern:
(define-mustache-character #\& (make-instance 'ampersand-tag :text arg-text))

Problem: Macro call that should be transformed by define

Macro definition:
(defmacro define (name template)
  "Define a named renderer of string TEMPLATE."
  `(setf (symbol-function ',name)
         (compile-template ,template)))

Macroexpansion:
(set-mustache-character #\AMPERSAND (lambda (raw-text arg-text escapep start end) (declare (ignorable raw-text arg-text escapep start end) (type simple-string raw-text arg-text) (boolean escapep) (offset start end)) (make-instance (quote ampersand-tag) :text arg-text)))
Generate a defmacro form that transforms code like this:
(define-simple-definition-resolver function designator-function-p)

Pattern to recognize: 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 function (function #:package133) (when (ignore-errors (designator-function-p function)) (list (make-instance (quote function) :designator function :package #:package133))))
Define a macro that eliminates this repetitive pattern:
(lambda* nil)

Issue: Macro call that should be transformed by LAMBDA*

Macro definition:
(defmacro LAMBDA* ...)

Macroexpansion:
(lambda () (with-yield))
Define a macro that eliminates this repetitive pattern:
(set-custom-vars :integer #'parse-number :real #'parse-number :boolean #'json-boolean-to-lisp :beginning-of-array #'make-vector-accumulator :array-element #'vector-accumulator-add :end-of-array #'vector-accumulator-get-sequence :beginning-of-object #'make-accumulator-with-prototype :object-key #'accumulator-add-key-or-set-prototype :object-value #'accumulator-add-value-or-set-prototype :end-of-object #'accumulator-get-object :beginning-of-string #'make-vector-accumulator :string-char #'vector-accumulator-add :end-of-string #'vector-accumulator-get-string)

Issue: Macro call that should be transformed by set-custom-vars

Macro definition:
(defmacro set-custom-vars (&rest key-args)
  `(setq
    ,@(loop for (supplied-key value) on key-args by #'cddr
         append (loop for (var . var-key) in *custom-vars*
                   thereis (if (eql var-key supplied-key)
                               (list var value))))))

Macroexpansion:
(setq *integer-handler* (function parse-number) *real-handler* (function parse-number) *boolean-handler* (function json-boolean-to-lisp) *beginning-of-array-handler* (function make-vector-accumulator) *end-of-array-handler* (function vector-accumulator-get-sequence) *beginning-of-object-handler* (function make-accumulator-with-prototype) *object-key-handler* (function accumulator-add-key-or-set-prototype) *object-value-handler* (function accumulator-add-value-or-set-prototype) *end-of-object-handler* (function accumulator-get-object) *beginning-of-string-handler* (function make-vector-accumulator) *string-char-handler* (function vector-accumulator-add) *end-of-string-handler* (function vector-accumulator-get-string))
Write a Common Lisp macro to handle this code pattern:
(define-library compression-lib)

Problem: Macro call that should be transformed by define-library

Macro definition:
(defmacro define-library (name &body initargs)
  #+cffi
  `(change-class (cffi::get-foreign-library ',name)
                 'library
                 ,@initargs)
  #-cffi
  `(make-instance 'library ,@initargs))

Macroexpansion:
(change-class (cffi::get-foreign-library (quote compression-lib)) (quote library))
Write a Common Lisp macro to handle this code pattern:
(define-simple-type-map function cl:function)

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

Macro definition:
(defmacro define-simple-type-map (class type)
  `(defmethod type ((,class ,class))
     ',type))

Macroexpansion:
(defmethod type ((function function)) (quote common-lisp:function))
Create a Common Lisp macro for the following transformation. Before code:
(*> +comma+ +consume-space+)

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 (#:*>-offset172) (multiple-value-bind (#:*>-res173 #:*>-next174) (funcall +comma+ #:*>-offset172) (if (ok? #:*>-res173) (funcall +consume-space+ #:*>-next174) (fail #:*>-next174))))
Create a Common Lisp macro for the following transformation. Before code:
(matrix-case nil)

What needs to change: Macro call that should be transformed by MATRIX-CASE

Macro definition:
(defmacro MATRIX-CASE ...)

Macroexpansion:
nil
You are a Common Lisp macro expert. Given this code pattern:
(with-inactive-layers nil
  :key
  nil)

Write a macro that addresses: Macro call that should be transformed by WITH-INACTIVE-LAYERS

Macro definition:
(defmacro WITH-INACTIVE-LAYERS ...)

Macroexpansion:
(progn :key nil)
Define a macro that eliminates this repetitive pattern:
(with-wcs-math-error-handling (ret (log1+ x)) (check-wcs-math-result))

Issue: Macro call that should be transformed by with-wcs-math-error-handling

Macro definition:
(defmacro with-wcs-math-error-handling
    ((var-or-var-list
      (function x &optional (y nil y-supplied-p))
      &rest keyargs
      &key underflow-value)
     &body body)
  (declare (ignorable underflow-value))
  (let ((x_ (gensym)) (y_ (gensym)) (args_ (gensym))
        (var-list (ensure-list var-or-var-list)))
    `(let* ((,x_ ,x)
            (,y_ ,y)
            (,args_ (list ,x_ ,@(if y-supplied-p `(,y_)))))
       (declare (ignorable ,y_)
                (type list ,args_)
                (dynamic-extent ,args_))
       (catch 'return-from-with-wcs-math-error-handling
         (multiple-value-bind ,var-list
             (call-with-wcs-math-error-handler ',function ,args_
                                               ,@keyargs)
           (flet ((check-wcs-math-result
                      (&optional (ret ,(first var-list))
                                 (arg-list ,args_))
                    (check-wcs-math-result ret arg-list)))
             ,@body))))))

Macroexpansion:
(let* ((#:g227 x) (#:g228 nil) (#:g229 (list #:g227))) (declare (ignorable #:g228) (type list #:g229) (dynamic-extent #:g229)) (catch (quote return-from-with-wcs-math-error-handling) (multiple-value-bind (ret) (call-with-wcs-math-error-handler (quote log1+) #:g229) (flet ((check-wcs-math-result (&optional (ret ret) (arg-list #:g229)) (check-wcs-math-result ret arg-list))) (check-wcs-math-result)))))
Define a macro that eliminates this repetitive pattern:
(with-table node hash depth (bitmap array bits index hit) (when hit (%hamt-lookup (aref array index) key hash (1+ depth) test)))

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

Macro definition:
(defmacro with-table (node hash depth
                      (bitmap array bits index hit)
                      &body body)
  "Bitshifting in HAMT tables"
  `(let* ((,bitmap (table-bitmap ,node))
          (,array (table-array ,node))
          (,bits (get-bits ,hash ,depth))
          (,index (get-index ,bits ,bitmap))
          (,hit (logbitp ,bits ,bitmap)))
     ,@body))

Macroexpansion:
(let* ((bitmap (table-bitmap node)) (array (table-array node)) (bits (get-bits hash depth)) (index (get-index bits bitmap)) (hit (logbitp bits bitmap))) (when hit (%hamt-lookup (aref array index) key hash (1+ depth) test)))
Define a macro that eliminates this repetitive pattern:
(receive x (values) x)

Issue: Macro call that should be transformed by receive

Macro definition:
(defmacro receive (formals expr &body body)
  "Stricter version of `multiple-value-bind'.

Use `receive' when you want to enforce that EXPR should return a
certain number of values, or a minimum number of values.

If FORMALS is a proper list, then EXPR must return exactly as many
values -- no more and no less -- as there are variables in FORMALS.

If FORMALS is an improper list (VARS . REST), then EXPR must return at
least as many values as there are VARS, and any further values are
bound, as a list, to REST.

Lastly, if FORMALS is a symbol, bind that symbol to all the values
returned by EXPR, as if by `multiple-value-list'.

From Scheme (SRFI-8)."
  ;; It's probably not worth stack-allocating the thunk.
  (cond ((null formals)
         `(multiple-value-call
              (lambda ()
                ,@body)
            ,expr))
        ((atom formals)
         ;; This could also be written:
         #+(or) `(let ((,formals (multiple-value-list ,expr)))
                   ,@body)
         ;; But I want it to be possible to declare FORMALS to have
         ;; dynamic extent, and most Lisps support that for &rest
         ;; lists.
         `(multiple-value-call
              (lambda (&rest ,formals)
                ,@body)
            ,expr))
        ((proper-list-p formals)
         (when (intersection formals lambda-list-keywords)
           (error "Lambda list keywords in formals: ~a" formals))
         `(multiple-value-call
              (lambda ,formals
                ,@body)
            ,expr))
        (t (let* ((last (last formals))
                  (vars (append (butlast formals)
                                (list (car last))))
                  (rest (cdr last)))
             (when (intersection (cons rest vars) lambda-list-keywords)
               (error "Lambda list keywords in formals: ~a" formals))
             `(multiple-value-call
                  (lambda (,@vars &rest ,rest)
                    ,@body)
                ,expr)))))

Macroexpansion:
(multiple-value-call (lambda (&rest x) x) (values))
Write a Common Lisp macro to handle this code pattern:
(yield-all (flatten (car list)))

Problem: 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 (#:g184 (flatten (car list))) (yield #:g184))