j14i/cl-macros huggingface dataset:
Write a Common Lisp macro to handle this code pattern:
(with-html-string (:raw "Very very very very very very very very very very very very very very very very very very very very very very very very long line"))

Problem: 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 (:raw "Very very very very very very very very very very very very very very very very very very very very very very very very long line")))
Create a Common Lisp macro for the following transformation. Before code:
(-> :g () (mt:open-latch latch))

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

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

Macroexpansion:
(atomically :g nil (cl-muth:open-latch latch))
You are a Common Lisp macro expert. Given this code pattern:
(*> +consume-space+ +close-brace+)

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 (#:*>-offset181) (multiple-value-bind (#:*>-res182 #:*>-next183) (funcall +consume-space+ #:*>-offset181) (if (ok? #:*>-res182) (funcall +close-brace+ #:*>-next183) (fail #:*>-next183))))
Write a Common Lisp macro to handle this code pattern:
(collect-hash nil nil)

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

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

Macroexpansion:
(common-lisp:let* ((#:out-138 (make-hash-table)))
  (common-lisp:let ((#:generator-142 (generator nil))
                    #:values-134
                    (#:generator-140 (generator nil))
                    #:keys-133)
    (declare (type generator #:generator-142)
             (type generator #:generator-140))
    (tagbody
     #:ll-143
      (setq #:values-134 (next-in #:generator-142 (go end)))
      (setq #:keys-133 (next-in #:generator-140 (go end)))
      (setf (gethash #:keys-133 #:out-138) #:values-134)
      (go #:ll-143)
     end)
    #:out-138))
Create a Common Lisp macro for the following transformation. Before code:
(form &aux (result T))

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

Macro definition:
(defmacro for (&environment env bindings &body body)
  (let ((*environment* env))
    (multiple-value-bind (bind-init bind-forms bind-exit bind-post) (convert-bindings bindings)
      (multiple-value-bind (clause-init body-forms clause-exit) (convert-clauses body)
        `(with-interleaving
           ,@bind-init
           ,@clause-init
           (with-for-block ()
             (with-for-tagbody
                 (progn ,@bind-forms
                        ,@body-forms
                        ,@bind-post)
               (return-for
                ,@clause-exit
                ,@bind-exit))))))))

Macroexpansion:
(form &aux (result t))
You are a Common Lisp macro expert. Given this code pattern:
(defsynonym maximize :max)

Write a macro that addresses: 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 maximize) (quote synonym)) (quote :max)))
Define a macro that eliminates this repetitive pattern:
(regex-apropos-aux (regex packages case-insensitive) (print-symbol-info symbol))

Issue: Macro call that should be transformed by regex-apropos-aux

Macro definition:
(defmacro regex-apropos-aux ((regex packages case-insensitive &optional return-form)
                             &body body)
  "Auxiliary macro used by REGEX-APROPOS and REGEX-APROPOS-LIST.
Loops through PACKAGES and executes BODY with SYMBOL bound to each
symbol which matches REGEX.  Optionally evaluates and returns
RETURN-FORM at the end.  If CASE-INSENSITIVE is true and REGEX isn't
already a scanner, a case-insensitive scanner is used."
  (with-rebinding (regex)
    (with-unique-names (scanner %packages hash)
      `(let* ((,scanner (create-scanner ,regex
                         :case-insensitive-mode
                         (and ,case-insensitive
                              (not (functionp ,regex)))))
              (,%packages (or ,packages
                             (list-all-packages)))
              (,hash (make-hash-table :test #'eq)))
        (do-with-all-symbols (symbol ,%packages)
          (unless (gethash symbol ,hash)
            (when (scan ,scanner (symbol-name symbol))
              (setf (gethash symbol ,hash) t)
              ,@body)))
        ,return-form))))

Macroexpansion:
(let ((#:regex149 regex)) (let* ((#:scanner150 (create-scanner #:regex149 :case-insensitive-mode (and case-insensitive (not (functionp #:regex149))))) (#:%packages151 (or packages (list-all-packages))) (#:hash154 (make-hash-table :test (function eq)))) (with-package-iterator (#:next152 #:%packages151 :external :internal :inherited) (loop (multiple-value-bind (#:morep153 symbol) (#:next152) (unless #:morep153 (return nil)) (unless (gethash symbol #:hash154) (when (scan #:scanner150 (symbol-name symbol)) (setf (gethash symbol #:hash154) t) (print-symbol-info symbol))))))))
You are a Common Lisp macro expert. Given this code pattern:
(sum-of nil
  nil)

Write a macro that addresses: Macro call that should be transformed by SUM-OF

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

Macroexpansion:
(lc (nil nil) sum)
You are a Common Lisp macro expert. Given this code pattern:
(is-print (princ "ABCDEFGH") "ABCDEFGHIJKLMNO")

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

Macro definition:
(defmacro is (got expected &rest args)
  (with-gensyms (duration result new-args desc)
    (once-only (expected)
      `(let* ((,new-args (list ,@args))
              (,desc (parse-description-and-test ,new-args)))
         (with-catching-errors (:description ,desc :expected ,expected)
           (with-duration ((,duration ,result) ,got)
             (test ,result ,expected ,new-args
                   :duration ,duration)))))))

Macroexpansion:
(let ((#:expected175 "ABCDEFGHIJKLMNO") (#:desc176 nil)) (with-catching-errors (:description #:desc176 :expected #:expected175) (let* (#:duration173 (#:output172 (with-output-to-string (*standard-output*) (with-duration ((#:duration-inner174 #:output172) (princ "ABCDEFGH")) (declare (ignore #:output172)) (setq #:duration173 #:duration-inner174))))) (test #:output172 #:expected175 #:desc176 :duration #:duration173 :got-form (quote (princ "ABCDEFGH")) :test-fn (function string=) :report-expected-label "output"))))
Write a Common Lisp macro to handle this code pattern:
(sunless x (setf it :oops))

Problem: Macro call that should be transformed by sunless

Macro definition:
(defmacro sunless (test &body body)
  "Like UNLESS, except binds the test form to IT (via SYMBOL-MACROLET) for the
scope of the body. IT can be set with SETF."
  `(symbolic unless ,test ,@body))

Macroexpansion:
(symbolic unless x (setf it :oops))
Write a Common Lisp macro to handle this code pattern:
(defgeneric nil nil)

Problem: Macro call that should be transformed by DEFGENERIC

Macro definition:
(defmacro DEFGENERIC ...)

Macroexpansion:
(common-lisp:defgeneric nil
    nil)
Generate a defmacro form that transforms code like this:
(define-shell-component sass :input-type "scss" :output-type "css" :shell-command "sass")

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 sass :input-type "scss" :output-type "css" :compile-function (lambda (input-pathname output-pathname) (inferior-shell:run (list "sass" input-pathname output-pathname) :show t)))
Create a Common Lisp macro for the following transformation. Before code:
(define-simple-error-for sffi-continuable-error)

What needs to change: Macro call that should be transformed by define-simple-error-for

Macro definition:
(defmacro define-simple-error-for (base-type &key name object-initarg)
  "Define a simple error subclassing from BASE-TYPE and a corresponding
function, analogous to ERROR, but also optionally taking the object 
against which to err, and passing it to ERROR via the OBJECT-INITARG
keyword. The name of the simple error is constructed by prepending
'SIMPLE-' to BASE-TYPE.
Whether or not the error signaller will require and pass the
object is specified by OBJECT-INITARG being non-NIL."
  `(define-simple-condition-for ,base-type :object-initarg ,object-initarg :simple-condition-type simple-error :signaler error
                                ,@(when name `(:name ,name))))

Macroexpansion:
(define-simple-condition-for sffi-continuable-error :object-initarg nil :simple-condition-type simple-error :signaler error)
Define a macro that eliminates this repetitive pattern:
(quasiquote nil nil)

Issue: Macro call that should be transformed by QUASIQUOTE

Macro definition:
(defmacro QUASIQUOTE ...)

Macroexpansion:
(let ((#:source122 nil))
  (%quote #:source122 'nil))
Write a Common Lisp macro to handle this code pattern:
(defjs at() (let ((arr (make-array))) (setf (aref arr 0) 10) (setf (aref arr 1) 20) (setf (aref arr 2) 30) (setf (aref arr 4) 40) (setf (aref arr 5) 80) (return (aref arr 2))))

Problem: Macro call that should be transformed by defjs

Macro definition:
(defmacro defjs (name args &body body)
  "Define client side javascript. Works like defun; body is in lisp, with parenscript
   additions, like return. So (defjs hello (x y) (return (+ x y))) defines an adder. 
   macro creates a lisp function which sends the javascript function over to the mongo 
   server to be evaluated. Result is processed and returned to the reader. 
   This will execute 10 times on the server :
   (mapcar (lambda (x) (hello 10 x)) (list 1 2 3 4 5 6 7 8 9 10))"
  `(let* ((js-body (parenscript:ps (lambda ,args ,@body))))
     (setf (gethash ',name *js-definitions*) js-body)
     (defun ,name ,args
       (get-element "retval" (car (docs (db.eval js-body ,@args)))))))

Macroexpansion:
(let* ((js-body (parenscript:ps (lambda nil (let ((arr (make-array))) (setf (aref arr 0) 10) (setf (aref arr 1) 20) (setf (aref arr 2) 30) (setf (aref arr 4) 40) (setf (aref arr 5) 80) (return (aref arr 2))))))) (setf (gethash (quote at) *js-definitions*) js-body) (defun at nil (get-element "retval" (car (docs (db.eval js-body))))))
Generate a defmacro form that transforms code like this:
(with-trace-sql (execute-with-retry query binds))

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

Macro definition:
(defmacro with-trace-sql (&body body)
  `(let ((dbi:*sql-execution-hooks* (cons #'trace-sql
                                          dbi:*sql-execution-hooks*)))
     ,@body))

Macroexpansion:
(let ((*sql-execution-hooks* (cons (function trace-sql) *sql-execution-hooks*))) (execute-with-retry query binds))
Create a Common Lisp macro for the following transformation. Before code:
(assoc-cdr :userinfo--endpoint disc)

What needs to change: Macro call that should be transformed by assoc-cdr

Macro definition:
(defmacro assoc-cdr (key alist &optional (test '#'eql))
  `(cdr (assoc ,key ,alist :test ,test)))

Macroexpansion:
(cdr (assoc :userinfo--endpoint disc :test (function eql)))
Create a Common Lisp macro for the following transformation. Before code:
(ps-to-stream nil)

What needs to change: Macro call that should be transformed by PS-TO-STREAM

Macro definition:
(defmacro PS-TO-STREAM ...)

Macroexpansion:
(let ((*parenscript-stream* nil))
  (write-string "" *parenscript-stream*))
Generate a defmacro form that transforms code like this:
(compiler-macro-lambda (a) `(1- ,a))

Pattern to recognize: Macro call that should be transformed by compiler-macro-lambda

Macro definition:
(defmacro compiler-macro-lambda (lambda-list &body body)
  (introspect-environment:parse-compiler-macro (gensym "COMPILER-MACRO-LAMBDA")
                                               lambda-list
                                               body))

Macroexpansion:
(sb-int:named-lambda (compiler-macro #:compiler-macro-lambda146) (#:expr #:env) (declare (sb-c::lambda-list (a))) (declare (ignore #:env)) (sb-int:named-ds-bind (:macro #:compiler-macro-lambda146 . define-compiler-macro) (a) (sb-c::compiler-macro-args #:expr) (declare (sb-c::constant-value a) (sb-c::no-compiler-macro #:compiler-macro-lambda146)) (block #:compiler-macro-lambda146 (sb-int:quasiquote (1- #S(sb-impl::comma :expr a :kind 0))))))
Generate a defmacro form that transforms code like this:
(bind (((:labels doit (x)) (declare (type fixnum x)) (setf x (* 2 x)) (setf x (+ x 3)) x)) (ensure-same (doit 1) 5) (ensure-same (doit 2) 7))

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

Macro definition:
(defmacro bind ((&rest bindings) &body body)
  "Bind is a replacement for let*, destructuring-bind, multiple-value-bind and more. 

An example is probably the best way to describe its syntax:

    \(bind \(\(a 2\)
           \(\(b &rest args &key \(c 2\) &allow-other-keys\) '\(:a :c 5 :d 10 :e 54\)\)
           \(\(:values d e\) \(truncate 4.5\)\)
           \(\(:structure xxx- slot1 slot2\) \(make-xxx\)\)
           \(\(:flet name \(arg1 arg2\)\) \(+ arg1 arg2\)\)\)
         \(list a b c d e args\)\)

Simple bindings are as in let*. Destructuring is done if the first item
in a binding is a list. Multiple value binding is done if the first item
in a binding is a list and the first item in the list is ':values'. Other
forms have their own syntax. For example, :structure first has the conc
name and then slot names whereas :flet has the function name and a list
of arguments and then the function body (in an implicit progn)."
  (let (declarations)
    (loop while (and (consp (car body)) (eq (caar body) 'declare)) do
          (push (first body) declarations)
          (setf body (rest body)))
    (if bindings
	(let ((*all-declarations* (bind-expand-declarations (nreverse declarations))))
	  (prog1
	      (bind-macro-helper bindings body)
	    (check-for-unused-variable-declarations *all-declarations*)))
        `(locally
             ,@declarations
           ,@body))))

Macroexpansion:
(labels ((doit (x) (declare (type fixnum x)) (progn (setf x (* 2 x)) (setf x (+ x 3)) x))) (progn (ensure-same (doit 1) 5) (ensure-same (doit 2) 7)))
You are a Common Lisp macro expert. Given this code pattern:
(defsynonym :thereis :there-is)

Write a macro that addresses: 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 :thereis) (quote synonym)) (quote :there-is)))
Generate a defmacro form that transforms code like this:
(ematch0 tests (nil more-patterns) ((list* test t-rest) `(,intersection (guard1 ,(first syms) ,test ,@(first more-patterns) ,@(wrap-test (rest syms) t-rest (rest more-patterns))))))

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

Macro definition:
(defmacro ematch0 (what &body clauses)
  `(match0 ,what
     ,@clauses
     (_ (error "level0 match error!"))))

Macroexpansion:
(match0 tests (nil more-patterns) ((list* test t-rest) (sb-int:quasiquote (#S(sb-impl::comma :expr intersection :kind 0) (guard1 #S(sb-impl::comma :expr (first syms) :kind 0) #S(sb-impl::comma :expr test :kind 0) #S(sb-impl::comma :expr (first more-patterns) :kind 2) #S(sb-impl::comma :expr (wrap-test (rest syms) t-rest (rest more-patterns)) :kind 2))))) (_ (error "level0 match error!")))
Create a Common Lisp macro for the following transformation. Before code:
(define-simple-documentation-lookup method-combination cl:method-combination)

What needs to change: Macro call that should be transformed by define-simple-documentation-lookup

Macro definition:
(defmacro define-simple-documentation-lookup (class documentation-type)
  `(defmethod documentation ((,class ,class))
     ,(if (eql documentation-type T)
          `(cl:documentation (object ,class) 'T)
          `(cl:documentation (designator ,class) ',documentation-type))))

Macroexpansion:
(defmethod documentation ((method-combination method-combination)) (common-lisp:documentation (designator method-combination) (quote common-lisp:method-combination)))
Write a Common Lisp macro to handle this code pattern:
(augment body-code (funcall body-during form body))

Problem: Macro call that should be transformed by augment

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

Macroexpansion:
(setf body-code (nconc body-code (funcall body-during form body)))
Create a Common Lisp macro for the following transformation. Before code:
(defstore example (a b))

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

Macro definition:
(defmacro defstore (store-name store-lambda-list &body body &environment env)
  (let* ((store-class-name (second (find :store-class body :key #'first)))
         (store-class (etypecase store-class-name
                        (null (find-class 'standard-store))
                        (symbol (find-class store-class-name))))
         (form (apply #'defstore-using-class store-class store-name store-lambda-list
                      :environment env
                      (mapcan #'(lambda (item)
                                  (cond ((eql (first item) :store-class)
                                         `(:store-class ',store-class-name))
                                        ((and (member (first item) '(:documentation :specialization-class)))
                                         (if (= 2 (length item))
                                             item
                                             (error "Invalid store definition option: ~W." item)))
                                        (t
                                         (list (first item) (rest item)))))
                              body))))
    `(eval-when (:compile-toplevel :load-toplevel :execute)
       ,form)))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (ensure-store (quote example) (quote (a b)))))
Write a Common Lisp macro to handle this code pattern:
(enable-reader-syntax nil :key nil)

Problem: Macro call that should be transformed by ENABLE-READER-SYNTAX

Macro definition:
(defmacro ENABLE-READER-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (push *readtable* *previous-readtables*)
  (setq *readtable* (copy-readtable))
  (%enable-reader-syntax *readtable* nil :key nil))
You are a Common Lisp macro expert. Given this code pattern:
(->> nil (progn))

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

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

Macroexpansion:
(progn nil)
You are a Common Lisp macro expert. Given this code pattern:
(defproto nil :key nil)

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

Macro definition:
(defmacro DEFPROTO ...)

Macroexpansion:
(progn
 (declaim (special nil))
 (eval-when (:compile-toplevel))
 (setf (symbol-value 'nil)
         (ensure-object (when (boundp 'nil) (symbol-value 'nil)) (list :key)
                        :properties (list) :nickname 'nil)))
Generate a defmacro form that transforms code like this:
(symbol-value-in-$instance nil (progn))

Pattern to recognize: Macro call that should be transformed by SYMBOL-VALUE-IN-$INSTANCE

Macro definition:
(defmacro SYMBOL-VALUE-IN-$INSTANCE ...)

Macroexpansion:
(slot-value nil (progn))
Create a Common Lisp macro for the following transformation. Before code:
(match ARG (PATTERN) (otherwise BODY...))

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

Macro definition:
(defmacro match (arg &body clauses)
  "Matches ARG with CLAUSES. CLAUSES is a list of the form of (PATTERN
. BODY) where PATTERN is a pattern specifier and BODY is an implicit
progn. If ARG matches some PATTERN, `match` then evaluates
the corresponding BODY and returns the evaluated value.  If no pattern matches,
then returns NIL.

Evaluating a form (FAIL) in the clause body causes the latest pattern
matching to fail. For example,

    (match 1
      (x (if (eql x 1)
             (fail)
             x))
      (_ 'ok))

returns OK, because the form (FAIL) in the first clause is
evaluated.

If BODY starts with the symbols WHEN or UNLESS, then the next form
will be used to introduce (FAIL). That is,

    (match list ((list x) when (oddp x) x))
    (match list ((list x) unless (evenp x) x))

will be translated to

    (match list ((list x) (if (oddp x) x (fail))))
    (match list ((list x) (if (evenp x) (fail) x)))

Examples:

    (match 1 (1 1))
    => 1
    (match 1 (2 2))
    => 2
    (match 1 (x x))
    => 1
    (match (list 1 2 3)
      (list x y z) (+ x y z))
    => 6"
  (compile-match-1 arg clauses nil))

Macroexpansion:
(%or (%or (let ((pattern arg))) body... (fail)) nil)
Create a Common Lisp macro for the following transformation. Before code:
(specializing nil
    nil)

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

Macro definition:
(defmacro SPECIALIZING ...)

Macroexpansion:
(let ((#:table147 (load-time-value (table 66))))
  (declare (optimize (speed 3) (debug 0) (safety 0)))
  (progn (funcall (the (function nil *) #:table147))))
You are a Common Lisp macro expert. Given this code pattern:
(define FILENAME_MAX 1024)

Write a macro that addresses: 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 filename_max) *preprocessor-defines*) #A((4) base-char . "1024"))) (defparameter filename_max 1024))
Create a Common Lisp macro for the following transformation. Before code:
(defclause options (&rest args &key name atomic-updates) (declare (ignore name atomic-updates)) (make-options :map args))

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 options (&rest args &key name atomic-updates) (declare (ignore name atomic-updates)) (make-options :map args)) (pushnew (quote options) *clauses*))