j14i/cl-macros huggingface dataset:
Create a Common Lisp macro for the following transformation. Before code:
(with-wcs-math-error-handling (ret (log x (float 10 x))) (check-wcs-math-result))

What needs to change: 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* ((#:g224 x) (#:g225 (float 10 x)) (#:g226 (list #:g224 #:g225))) (declare (ignorable #:g225) (type list #:g226) (dynamic-extent #:g226)) (catch (quote return-from-with-wcs-math-error-handling) (multiple-value-bind (ret) (call-with-wcs-math-error-handler (quote log) #:g226) (flet ((check-wcs-math-result (&optional (ret ret) (arg-list #:g226)) (check-wcs-math-result ret arg-list))) (check-wcs-math-result)))))
Create a Common Lisp macro for the following transformation. Before code:
(letmatch nil
    nil)

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

Macro definition:
(defmacro LETMATCH ...)

Macroexpansion:
(ifmatch (nil nil nil (error "LETMATCH:  mismatch.")))
Define a macro that eliminates this repetitive pattern:
(some->> nil nil)

Issue: Macro call that should be transformed by SOME->>

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

Macroexpansion:
(let* ((#:g126 nil))
  (if (null #:g126)
      nil
      (->> #:g126 nil)))
Define a macro that eliminates this repetitive pattern:
(lexpr-$send nil :key nil)

Issue: Macro call that should be transformed by LEXPR-$SEND

Macro definition:
(defmacro LEXPR-$SEND ...)

Macroexpansion:
(apply #'send-message nil :key nil)
You are a Common Lisp macro expert. Given this code pattern:
(destructuring-match nil
  (progn))

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

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

Macroexpansion:
(let ((#:form nil))
  (block #:done
    (let ((#:done
           (lambda (&rest values)
             (declare (dynamic-extent values))
             (return-from #:done (values-list values)))))
      (tagbody
        (funcall
         (lambda (#:thing #:fail)
           (let ((progn #:thing) (#:thing 'nil))
             (if (not (null #:thing))
                 (org.tfeb.dsm/impl::fail #:fail "extra arguments")
                 (locally (multiple-value-call #:done (progn))))))
         #:form
         (lambda (message arguments)
           (declare (ignore message arguments))
           (go #:next)))
       #:next))))
You are a Common Lisp macro expert. Given this code pattern:
(alter nil (progn))

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

Macro definition:
(defmacro ALTER ...)

Macroexpansion:
(compiler-let ((*optimize-series-expressions* nil)) (alter nil (progn)))
Define a macro that eliminates this repetitive pattern:
(deferror "42501" insufficient-privilege syntax-error-or-access-violation)

Issue: Macro call that should be transformed by deferror

Macro definition:
(defmacro deferror (code typename &optional (superclass 'database-error))
  `(progn (define-condition ,typename (,superclass) ())
          (setf (gethash ,code *error-table*) ',typename)))

Macroexpansion:
(progn (define-condition insufficient-privilege (syntax-error-or-access-violation) nil) (setf (gethash "42501" *error-table*) (quote insufficient-privilege)))
Generate a defmacro form that transforms code like this:
(as-> nil :key nil)

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

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

Macroexpansion:
(let* ((:key nil) (:key nil))
  :key)
Create a Common Lisp macro for the following transformation. Before code:
(with-decoder-simple-list-semantics (let ((*json-symbols-package* 'json-test)) (decode-json-from-string encoded)))

What needs to change: Macro call that should be transformed by with-decoder-simple-list-semantics

Macro definition:
(defmacro with-decoder-simple-list-semantics (&body body)
  "Execute BODY in a dynamic environement where the decoder semantics
is such as set by SET-DECODER-SIMPLE-LIST-SEMANTICS."
  `(with-shadowed-custom-vars
     (set-decoder-simple-list-semantics)
     ,@body))

Macroexpansion:
(with-shadowed-custom-vars (set-decoder-simple-list-semantics) (let ((*json-symbols-package* (quote json-test))) (decode-json-from-string encoded)))
Generate a defmacro form that transforms code like this:
(defun/1 fputs (str fd) (handler-case (progn (write-string (char*-to-string str) (fd-stream fd)) 0) (error () (setf (ferror fd) EIO) EOF)))

Pattern to recognize: Macro call that should be transformed by defun/1

Macro definition:
(defmacro defun/1 (name arglist &body body)
  "Lisp-1 defun; makes function pointers work."
  `(progn
     (defun ,name ,arglist
       (declare (optimize (speed 0) (debug 3)
                          ;; FIXME: Why do minor warnings result in load errors?
                          #+sbcl (sb-ext:inhibit-warnings 3)))
        
       ,@body)
     (defparameter ,name (vacietis.c:mkptr& (symbol-function ',name)))))

Macroexpansion:
(progn (defun fputs (str fd) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (handler-case (progn (write-string (char*-to-string str) (fd-stream fd)) 0) (error nil (setf (ferror fd) eio) eof))) (defparameter fputs (vacietis.c:mkptr& (symbol-function (quote fputs)))))
Define a macro that eliminates this repetitive pattern:
(defun-compile-time indirect-callers-internal (function-names callers) (if (null function-names) callers (let ((function-name (first function-names))) (if (member function-name callers :test #'equal) (indirect-callers-internal (rest function-names) callers) (indirect-callers-internal (rest function-names) (indirect-callers-internal (callers function-name) (cons function-name callers)))))))

Issue: Macro call that should be transformed by defun-compile-time

Macro definition:
(defmacro defun-compile-time (function-name lambda-list &body body)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (cl:defun ,function-name ,lambda-list ,@body)
     (eval-when (:compile-toplevel) (compile ',function-name))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:defun indirect-callers-internal (function-names callers) (if (null function-names) callers (let ((function-name (first function-names))) (if (member function-name callers :test (function equal)) (indirect-callers-internal (rest function-names) callers) (indirect-callers-internal (rest function-names) (indirect-callers-internal (callers function-name) (cons function-name callers))))))) (eval-when (:compile-toplevel) (compile (quote indirect-callers-internal))))
Define a macro that eliminates this repetitive pattern:
(bind (((:structure metabang-bind-test-1- (my-a a) c) c1) ((:structure metabang-bind-test-1- a b (second-c c)) c2)) (list my-a c a b second-c))

Issue: 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:
(let* ((#:|values-193| c1) (my-a (metabang-bind-test-1-a #:|values-193|)) (c (metabang-bind-test-1-c #:|values-193|)) (#:|values-192| c2) (a (metabang-bind-test-1-a #:|values-192|)) (b (metabang-bind-test-1-b #:|values-192|)) (second-c (metabang-bind-test-1-c #:|values-192|))) (declare (ignorable #:|values-193|)) (declare (ignorable #:|values-192|)) (progn (list my-a c a b second-c)))
Create a Common Lisp macro for the following transformation. Before code:
(with-flow-function-macro (body-fu lambda-list fu-body) `(dispatch-asynchronously ,flow-context #',body-fu))

What needs to change: Macro call that should be transformed by with-flow-function-macro

Macro definition:
(defmacro with-flow-function-macro ((fu-name fu-lambda-list fu-body) &body body)
  `(with-gensyms (,fu-name)
     `(%with-flow-function (,,fu-name ,,fu-lambda-list ,@,fu-body)
        ,,@body)))

Macroexpansion:
(with-gensyms (body-fu) (sb-int:quasiquote (%with-flow-function (#S(sb-impl::comma :expr body-fu :kind 0) #S(sb-impl::comma :expr lambda-list :kind 0) #S(sb-impl::comma :expr fu-body :kind 2)) #S(sb-impl::comma :expr (sb-int:quasiquote (dispatch-asynchronously #S(sb-impl::comma :expr flow-context :kind 0) (function #S(sb-impl::comma :expr body-fu :kind 0)))) :kind 0))))
Define a macro that eliminates this repetitive pattern:
(define-component parenscript :input-type "lisp" :output-type "js" :compile-function (lambda (input-pathname output-pathname) (with-open-file (stream output-pathname :direction :output :if-exists :supersede :if-does-not-exist :create) (write-string (parenscript:ps-compile-file input-pathname) stream))))

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

Macro definition:
(defmacro define-component (name &key input-type output-type compile-function)
  "Define an ASDF component."
  `(progn
     (defclass ,name (source-file)
       ((type :initform ,input-type)
        (output :reader output :initarg :output)))

     (defmethod perform ((o load-op) (component ,name)) t)

     (defmethod output-files ((operation compile-op) (component ,name))
       (list
        (output-pathname component ,output-type)))

     (defmethod perform ((o compile-op) (component ,name))
       (funcall ,compile-function
                (component-pathname component)
                (output-pathname component ,output-type)))

     (import ',name :asdf)))

Macroexpansion:
(progn (defclass parenscript (source-file) ((type :initform "lisp") (output :reader output :initarg :output))) (defmethod perform ((o load-op) (component parenscript)) t) (defmethod output-files ((operation compile-op) (component parenscript)) (list (output-pathname component "js"))) (defmethod perform ((o compile-op) (component parenscript)) (funcall (lambda (input-pathname output-pathname) (with-open-file (stream output-pathname :direction :output :if-exists :supersede :if-does-not-exist :create) (write-string (parenscript:ps-compile-file input-pathname) stream))) (component-pathname component) (output-pathname component "js"))) (import (quote parenscript) :asdf))
Create a Common Lisp macro for the following transformation. Before code:
(untrace$method 'some-name)

What needs to change: Macro call that should be transformed by UNTRACE$METHOD

Macro definition:
(defmacro UNTRACE$METHOD ...)

Macroexpansion:
(mcs-untrace quote some-name)
You are a Common Lisp macro expert. Given this code pattern:
(signal-syntax-error* start-pos "Missing right bracket to close character class.")

Write a macro that addresses: 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 start-pos :format-control "Missing right bracket to close character class." :format-arguments (list))
You are a Common Lisp macro expert. Given this code pattern:
(with-xml-group-element (s "tspan" opts) (string->xml s text))

Write a macro that addresses: Macro call that should be transformed by with-xml-group-element

Macro definition:
(defmacro with-xml-group-element ((stream element properties) &body body)
  (let ((s (gensym "stream"))
        (e (gensym "element")))
    `(let ((,s ,stream)
           (,e ,element))
       (begin-group->xml ,s ,e ,properties)
       (with-indentation 
         ,@body)
       (end-group->xml ,s ,e))))

Macroexpansion:
(let ((#:|stream134| s) (#:|element135| "tspan")) (begin-group->xml #:|stream134| #:|element135| opts) (with-indentation (string->xml s text)) (end-group->xml #:|stream134| #:|element135|))
Generate a defmacro form that transforms code like this:
(define-mustache-character #\! (make-instance 'comment-tag :text ""))

Pattern to recognize: 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 #\EXCLAMATION_MARK (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 comment-tag) :text "")))
Define a macro that eliminates this repetitive pattern:
(*> +consume-ws+ +any-crlf+)

Issue: 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 (#:*>-offset128) (multiple-value-bind (#:*>-res129 #:*>-next130) (funcall +consume-ws+ #:*>-offset128) (if (ok? #:*>-res129) (funcall +any-crlf+ #:*>-next130) (fail #:*>-next130))))
You are a Common Lisp macro expert. Given this code pattern:
(with-symbol-access
  nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by WITH-SYMBOL-ACCESS

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

Macroexpansion:
(let ((*symbol-access* t))
  nil
  (progn))
Generate a defmacro form that transforms code like this:
(enable-quasi-quoted-bivalent-to-binary-emitting-form-syntax 'some-name)

Pattern to recognize: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BIVALENT-TO-BINARY-EMITTING-FORM-SYNTAX

Macro definition:
(defmacro ENABLE-QUASI-QUOTED-BIVALENT-TO-BINARY-EMITTING-FORM-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-quasi-quoted-bivalent-to-binary-emitting-form-syntax-in-readtable
   'some-name :with-inline-emitting nil :declarations 'nil :start-character nil
   :end-character nil :unquote-character #\COMMA :splice-character
   #\COMMERCIAL_AT :destructive-splice-character #\FULL_STOP
   :dispatched-quasi-quote-name "biv" :encoding *default-character-encoding*)
  (values))
You are a Common Lisp macro expert. Given this code pattern:
(ƒƒ nil)

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

Macro definition:
(defmacro ƑƑ ...)

Macroexpansion:
(defun nil (&optional α) (cond))
Write a Common Lisp macro to handle this code pattern:
(*> +consume-space+ +close-bracket+)

Problem: 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 (#:*>-offset175) (multiple-value-bind (#:*>-res176 #:*>-next177) (funcall +consume-space+ #:*>-offset175) (if (ok? #:*>-res176) (funcall +close-bracket+ #:*>-next177) (fail #:*>-next177))))
Write a Common Lisp macro to handle this code pattern:
(-> :g (v) v)

Problem: Macro call that should be transformed by ->

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

Macroexpansion:
(atomically :g (v) v)
Create a Common Lisp macro for the following transformation. Before code:
(js nil :key nil)

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

Macro definition:
(defmacro JS ...)

Macroexpansion:
(ps
  nil
  :key
  nil)
Generate a defmacro form that transforms code like this:
(def-neo4j-fun del-node-properties (node-id) :delete (:uri-spec (format nil "node/~A/properties" node-id)) (:status-handlers (204 (values t body)) (404 (error 'node-not-found-error :uri uri))))

Pattern to recognize: 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 del-node-properties (&key node-id) (let ((uri (format nil "node/~A/properties" node-id)) (json (encode-neo4j-json-payload nil :string))) (make-neo4j-request :delete uri json (list (list 204 (lambda (body uri json) (values t body))) (list 404 (lambda (body uri json) (error (quote node-not-found-error) :uri uri))))))))
Create a Common Lisp macro for the following transformation. Before code:
(defvariant nil)

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

Macro definition:
(defmacro DEFVARIANT ...)

Macroexpansion:
(progn
 (defstruct (nil (:constructor nil)))
 (defmacro match-nil (expr &body match-cases)
   #A((34) base-char . "Match values of variant type: NIL.")
   (let ((expr-var (gensym "-val")))
     `(let ((,expr-var ,expr))
        ,(build-dispatch `,'nil `,'nil match-cases expr-var)))))
Generate a defmacro form that transforms code like this:
(with-output-to-file (stream pathname :if-exists if-exists :if-does-not-exist if-does-not-exist :element-type '(unsigned-byte 8)) (write-sequence bytes stream))

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

Macro definition:
(defmacro with-output-to-file ((stream-name file-name &rest args
                                            &key (direction nil direction-p)
                                            &allow-other-keys)
			       &body body)
  "Evaluate BODY with STREAM-NAME to an output stream on the file
FILE-NAME. ARGS is sent as is to the call to OPEN except EXTERNAL-FORMAT,
which is only sent to WITH-OPEN-FILE when it's not NIL."
  (declare (ignore direction))
  (when direction-p
    (error "Can't specify :DIRECTION for WITH-OUTPUT-TO-FILE."))
  `(with-open-file* (,stream-name ,file-name :direction :output ,@args)
     ,@body))

Macroexpansion:
(with-open-file* (stream pathname :direction :output :if-exists if-exists :if-does-not-exist if-does-not-exist :element-type (quote (unsigned-byte 8))) (write-sequence bytes stream))
Generate a defmacro form that transforms code like this:
(with-html-string (:div (:section (:tag :name :h2 (:p "hello")))))

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

Macro definition:
(defmacro with-html (&body body &environment env)
  "Interpret BODY as HTML. Consult README.txt for the syntax."
  `(let ((*html* (ensure-html-stream *html*)))
     ,(if (and (null (cdr body)) (atom (car body)))
          (car body)
          `(progn ,@(parse-html body env)))))

Macroexpansion:
(with-output-to-string (*html*) (with-html (:div (:section (:tag :name :h2 (:p "hello"))))))
Generate a defmacro form that transforms code like this:
(lret* ((offset (- length (length vec))) (element-type (array-element-type vec)) (out (make-array length :element-type element-type))) (replace out vec :start1 offset) (fill out pad :end offset) out)

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

Macro definition:
(defmacro lret ((&rest bindings) &body body)
  "Return the initial value of the last binding in BINDINGS. The idea
is to create something, initialize it, and then return it.

    (lret ((x 1)
           (y (make-array 1)))
      (setf (aref y 0) x))
    => #(1)

Note that the value returned is the value initially bound. Subsequent
assignments are ignored.

    (lret ((x 1))
      (setf x 2))
    => 1

Furthermore, on Lisps that support it, the variable may be made
read-only, making assignment a compiler-time error.

`lret' may seem trivial, but it fufills the highest purpose a macro
can: it eliminates a whole class of bugs (initializing an object, but
forgetting to return it).

Cf. `aprog1' in Anaphora."
  `(lret-aux let ,bindings
     ,@body))

Macroexpansion:
(lret-aux let* ((offset (- length (length vec))) (element-type (array-element-type vec)) (out (make-array length :element-type element-type))) (replace out vec :start1 offset) (fill out pad :end offset) out)
Create a Common Lisp macro for the following transformation. Before code:
(->> nil nil)

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

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

Macroexpansion:
(nil)
Define a macro that eliminates this repetitive pattern:
(check-cursor-attached cluffer:end-of-line-p (cursor))

Issue: 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:end-of-line-p :before ((cursor cluffer:cursor)) (declare (ignore)) (unless (cluffer:cursor-attached-p cursor) (error (quote cluffer:cursor-detached))))