j14i/cl-macros huggingface dataset:
Define a macro that eliminates this repetitive pattern:
(with-input-from-file (input from :element-type element-type) (with-output-to-file (output to :element-type element-type :if-exists if-to-exists) (copy-stream input output :element-type element-type :finish-output finish-output)))

Issue: Macro call that should be transformed by with-input-from-file

Macro definition:
(defmacro with-input-from-file ((stream-name file-name &rest args
                                             &key (direction nil direction-p)
                                             &allow-other-keys)
                                &body body)
  "Evaluate BODY with STREAM-NAME to an input 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-INPUT-FROM-FILE."))
  `(with-open-file* (,stream-name ,file-name :direction :input ,@args)
     ,@body))

Macroexpansion:
(with-open-file* (input from :direction :input :element-type element-type) (with-output-to-file (output to :element-type element-type :if-exists if-to-exists) (copy-stream input output :element-type element-type :finish-output finish-output)))
Create a Common Lisp macro for the following transformation. Before code:
(lambda-ignoring-_ (_kwd exp) (expand-toplevel-const-exp exp))

What needs to change: Macro call that should be transformed by lambda-ignoring-_

Macro definition:
(defmacro lambda-ignoring-_ (lambda-list &body body)
  "Works like `cl:lambda' macro except automatically `declare's
 `ignore' for parameters beginning with '_' character."
  (let ((ignored-parameters
          (collect-_-symbol-in-lambda-list lambda-list)))
    (unless ignored-parameters
      (warn "No ignored parameters in: ~A" lambda-list))
    (multiple-value-bind (body decls doc)
        (parse-body body :documentation t)
      `(lambda ,lambda-list
         ,@ (if doc `(,doc))
         (declare (ignore ,@ignored-parameters))
         ,@decls
         ,@body))))

Macroexpansion:
(lambda (_kwd exp) (declare (ignore _kwd)) (expand-toplevel-const-exp exp))
Generate a defmacro form that transforms code like this:
(deferror "55" object-state-error)

Pattern to recognize: 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 object-state-error (database-error) nil) (setf (gethash "55" *error-table*) (quote object-state-error)))
Define a macro that eliminates this repetitive pattern:
(->> nil)

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

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

Macroexpansion:
nil
Define a macro that eliminates this repetitive pattern:
(def-neo4j-fun get-relationship-property (relationship-id property) :get (:uri-spec (format nil "relationship/~A/properties/~A" relationship-id (if (symbolp property) (string-downcase (symbol-name property)) property))) (:status-handlers (200 (decode-neo4j-json-output body)) (400 (error 'invalid-data-sent-error :uri uri :json json)) (404 (error 'property-not-found-error :uri uri))))

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

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

Macroexpansion:
(progn (defun get-relationship-property (&key relationship-id property) (let ((uri (format nil "relationship/~A/properties/~A" relationship-id (if (symbolp property) (string-downcase (symbol-name property)) property))) (json (encode-neo4j-json-payload nil :string))) (make-neo4j-request :get uri json (list (list 200 (lambda (body uri json) (decode-neo4j-json-output body))) (list 400 (lambda (body uri json) (error (quote invalid-data-sent-error) :uri uri :json json))) (list 404 (lambda (body uri json) (error (quote property-not-found-error) :uri uri))))))))
Create a Common Lisp macro for the following transformation. Before code:
(ignore-errors nil :key nil)

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

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

Macroexpansion:
(handler-case (progn nil :key nil) (error (condition) (values nil condition)))
Generate a defmacro form that transforms code like this:
(define-error invalid-shader-stage () (stage) "Sorry but '~a' is not a valid shader stage" stage)

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

Macro definition:
(defmacro define-error (name (&key (error-type 'varjo-error) (prefix "Varjo"))
                            (&rest args) error-string &body body)
  `(defcondition ,name (:error-type ,error-type :prefix ,prefix) ,args
       ,error-string ,@body))

Macroexpansion:
(defcondition invalid-shader-stage (:error-type varjo-error :prefix "Varjo") (stage) "Sorry but '~a' is not a valid shader stage" stage)
Define a macro that eliminates this repetitive pattern:
(with-html-string (:li :class (progn nil)))

Issue: 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 (:li :class (progn nil))))
Define a macro that eliminates this repetitive pattern:
(defun/1 fabs (x) (abs x))

Issue: 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 fabs (x) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (abs x)) (defparameter fabs (vacietis.c:mkptr& (symbol-function (quote fabs)))))
Define a macro that eliminates this repetitive pattern:
(def-neo4j-fun get-relationships-types () :get (:uri-spec "relationship/types") (:status-handlers (200 (decode-neo4j-json-output body))))

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

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

Macroexpansion:
(progn (defun get-relationships-types (&key) (let ((uri "relationship/types") (json (encode-neo4j-json-payload nil :string))) (make-neo4j-request :get uri json (list (list 200 (lambda (body uri json) (decode-neo4j-json-output body))))))))
Create a Common Lisp macro for the following transformation. Before code:
(when-let ((x 2) (y x)) (+ x y))

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

Macro definition:
(defmacro when-let (bindings &body forms)
    "Creates new variable bindings, and conditionally executes FORMS.

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, then FORMS are executed as an
implicit PROGN."
  (let* ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
                           (list bindings)
                           bindings))
         (variables (mapcar #'car binding-list)))
    `(let ,binding-list
       (when (and ,@variables)
         ,@forms))))

Macroexpansion:
(let ((x 2) (y x)) (when (and x y) (+ x y)))
Write a Common Lisp macro to handle this code pattern:
(with-dot nil
  (progn))

Problem: Macro call that should be transformed by WITH-DOT

Macro definition:
(defmacro with-dot (() &body body)
  `(progn ,@(replace-dot-calls body)))

Macroexpansion:
(progn (progn))
You are a Common Lisp macro expert. Given this code pattern:
(define-simple-definition-resolver ir1-convert (designator) (sb-int:info :function :ir1-convert designator))

Write a macro that addresses: 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 ir1-convert (ir1-convert #:package151) (when (ignore-errors (let ((designator ir1-convert)) (sb-int:info :function :ir1-convert designator))) (list (make-instance (quote ir1-convert) :designator ir1-convert :package #:package151))))
Generate a defmacro form that transforms code like this:
(mapping nil :key nil)

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

Macro definition:
(defmacro MAPPING ...)

Macroexpansion:
(mapping-mac nil
  :key
  nil)
Write a Common Lisp macro to handle this code pattern:
(unwind-protect nil
    nil)

Problem: Macro call that should be transformed by UNWIND-PROTECT

Macro definition:
(defmacro UNWIND-PROTECT ...)

Macroexpansion:
(common-lisp:unwind-protect nil)
You are a Common Lisp macro expert. Given this code pattern:
(collect-hash nil :key nil)

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

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

Macroexpansion:
(common-lisp:let* ((#:out-160 (make-hash-table nil)))
  (common-lisp:let ((#:generator-164 (generator :key))
                    #:values-156
                    (#:generator-162 (generator nil))
                    #:keys-155)
    (declare (type generator #:generator-164)
             (type generator #:generator-162))
    (tagbody
     #:ll-165
      (setq #:values-156 (next-in #:generator-164 (go end)))
      (setq #:keys-155 (next-in #:generator-162 (go end)))
      (setf (gethash #:keys-155 #:out-160) #:values-156)
      (go #:ll-165)
     end)
    #:out-160))
Define a macro that eliminates this repetitive pattern:
(js 'some-name)

Issue: Macro call that should be transformed by JS

Macro definition:
(defmacro JS ...)

Macroexpansion:
(ps
  'some-name)
You are a Common Lisp macro expert. Given this code pattern:
(check-cursor-attached cluffer:insert-item (cursor item))

Write a macro that addresses: 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:insert-item :before ((cursor cluffer:cursor) item) (declare (ignore item)) (unless (cluffer:cursor-attached-p cursor) (error (quote cluffer:cursor-detached))))
Write a Common Lisp macro to handle this code pattern:
(-<>>
  nil
  (progn))

Problem: Macro call that should be transformed by -<>>

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

Macroexpansion:
(let* ((#:var122 nil) (#:var123 (progn #:var122)))
  #:var123)
Write a Common Lisp macro to handle this code pattern:
(gathering nil
  nil)

Problem: Macro call that should be transformed by GATHERING

Macro definition:
(defmacro GATHERING ...)

Macroexpansion:
(common-lisp:let ()
  nil
  (values))
Write a Common Lisp macro to handle this code pattern:
(letrec-syntax common-lisp:nil common-lisp:nil)

Problem: Macro call that should be transformed by LETREC-SYNTAX

Macro definition:
(defmacro LETREC-SYNTAX ...)

Macroexpansion:
(common-lisp:macrolet ()
  common-lisp:nil)
Create a Common Lisp macro for the following transformation. Before code:
(define-element-maker :textarea "textArea" '(:x :y :width :height))

What needs to change: Macro call that should be transformed by define-element-maker

Macro definition:
(defmacro define-element-maker (element name required-attributes)
  `(progn
     (defmethod assert-required-attributes ((element (eql ,element)) attributes)
       (declare (ignore element))
       (unless (evenp (length attributes))
         (warn "attribute list may be missing data: ~A" attributes))
       (let ((missing (set-difference ,required-attributes attributes)))
	 (when missing
	   (error 'missing-attributes :message (format nil "~A missing attributes: ~{~A~^ ~}" ,element missing)))))
     (defmethod make-svg-element ((element (eql ,element)) attributes)
       (when *check-required-attributes*
         (assert-required-attributes element attributes))
       (make-instance 'svg-element :name ,name :attributes attributes))))

Macroexpansion:
(progn (defmethod assert-required-attributes ((element (eql :textarea)) attributes) (declare (ignore element)) (unless (evenp (length attributes)) (warn "attribute list may be missing data: ~A" attributes)) (let ((missing (set-difference (quote (:x :y :width :height)) attributes))) (when missing (error (quote missing-attributes) :message (format nil "~A missing attributes: ~{~A~^ ~}" :textarea missing))))) (defmethod make-svg-element ((element (eql :textarea)) attributes) (when *check-required-attributes* (assert-required-attributes element attributes)) (make-instance (quote svg-element) :name "textArea" :attributes attributes)))
Write a Common Lisp macro to handle this code pattern:
(define-alias-binding collect collecting)

Problem: Macro call that should be transformed by define-alias-binding

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

Macroexpansion:
(progn (setf (binding (quote collect)) (quote collecting)) (quote collect))
Create a Common Lisp macro for the following transformation. Before code:
(with-wcs-math-error-handling ((quotient remainder) (round x y)) (check-wcs-math-result) (values (coerce remainder 'double-float) (coerce quotient 'double-float)))

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* ((#:g260 x) (#:g261 y) (#:g262 (list #:g260 #:g261))) (declare (ignorable #:g261) (type list #:g262) (dynamic-extent #:g262)) (catch (quote return-from-with-wcs-math-error-handling) (multiple-value-bind (quotient remainder) (call-with-wcs-math-error-handler (quote round) #:g262) (flet ((check-wcs-math-result (&optional (ret quotient) (arg-list #:g262)) (check-wcs-math-result ret arg-list))) (check-wcs-math-result) (values (coerce remainder (quote double-float)) (coerce quotient (quote double-float)))))))
Define a macro that eliminates this repetitive pattern:
(when spec --indent (format stream "~&~a~a:" indent spec) ++indent)

Issue: 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 spec (progn --indent (format stream "~&~a~a:" indent spec) ++indent))
Write a Common Lisp macro to handle this code pattern:
(builder (:auth/basic :authenticator (lambda (user pass) (declare (ignore user pass)) t)) *app*)

Problem: Macro call that should be transformed by builder

Macro definition:
(defmacro builder (&rest app-or-middlewares)
  (let ((middlewares (butlast app-or-middlewares)))
    `(reduce #'funcall
             (remove-if
              #'null
              (list
               ,@(loop for mw in middlewares
                       when mw
                         collect (convert-to-middleware-form mw))))
             :initial-value (to-app ,(car (last app-or-middlewares)))
             :from-end t)))

Macroexpansion:
(reduce (function funcall) (remove-if (function null) (list (lambda (#:app176) (funcall (find-middleware :auth/basic) #:app176 :authenticator (lambda (user pass) (declare (ignore user pass)) t))))) :initial-value (to-app *app*) :from-end t)
Create a Common Lisp macro for the following transformation. Before code:
(define-error flow-id-must-be-specified-vv (:error-type varjo-critical-error) () "v-values must be given a flow id when created")

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

Macro definition:
(defmacro define-error (name (&key (error-type 'varjo-error) (prefix "Varjo"))
                            (&rest args) error-string &body body)
  `(defcondition ,name (:error-type ,error-type :prefix ,prefix) ,args
       ,error-string ,@body))

Macroexpansion:
(defcondition flow-id-must-be-specified-vv (:error-type varjo-critical-error :prefix "Varjo") nil "v-values must be given a flow id when created")
Define a macro that eliminates this repetitive pattern:
(unwind-protect-case () (random 10) (:always (push :always result)) (:normal (push :normal result)) (:abort (push :abort result)))

Issue: Macro call that should be transformed by unwind-protect-case

Macro definition:
(defmacro unwind-protect-case ((&optional abort-flag) protected-form &body clauses)
  "Like CL:UNWIND-PROTECT, but you can specify the circumstances that
the cleanup CLAUSES are run.

  clauses ::= (:NORMAL form*)* | (:ABORT form*)* | (:ALWAYS form*)*

Clauses can be given in any order, and more than one clause can be
given for each circumstance. The clauses whose denoted circumstance
occured, are executed in the order the clauses appear.

ABORT-FLAG is the name of a variable that will be bound to T in
CLAUSES if the PROTECTED-FORM aborted preemptively, and to NIL
otherwise.

Examples:

  (unwind-protect-case ()
       (protected-form)
     (:normal (format t \"This is only evaluated if PROTECTED-FORM executed normally.~%\"))
     (:abort  (format t \"This is only evaluated if PROTECTED-FORM aborted preemptively.~%\"))
     (:always (format t \"This is evaluated in either case.~%\")))

  (unwind-protect-case (aborted-p)
       (protected-form)
     (:always (perform-cleanup-if aborted-p)))
"
  (check-type abort-flag (or null symbol))
  (let ((gflag (gensym "FLAG+")))
    `(let ((,gflag t))
       (unwind-protect (multiple-value-prog1 ,protected-form (setf ,gflag nil))
	 (let ,(and abort-flag `((,abort-flag ,gflag)))
	   ,@(loop for (cleanup-kind . forms) in clauses
		   collect (ecase cleanup-kind
			     (:normal `(when (not ,gflag) ,@forms))
			     (:abort  `(when ,gflag ,@forms))
			     (:always `(progn ,@forms)))))))))

Macroexpansion:
(let ((#:flag+124 t)) (unwind-protect (multiple-value-prog1 (random 10) (setf #:flag+124 nil)) (let nil (progn (push :always result)) (when (not #:flag+124) (push :normal result)) (when #:flag+124 (push :abort result)))))
You are a Common Lisp macro expert. Given this code pattern:
(with-preprocessor-state-slots (state) (loop for i = (first token-list) while token-list until (eq i +newline-marker+) do (pop token-list) collect i))

Write a macro that addresses: 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 (loop for i = (first token-list) while token-list until (eq i +newline-marker+) do (pop token-list) collect i))
Create a Common Lisp macro for the following transformation. Before code:
(with-packages-unlocked nil)

What needs to change: Macro call that should be transformed by WITH-PACKAGES-UNLOCKED

Macro definition:
(defmacro WITH-PACKAGES-UNLOCKED ...)

Macroexpansion:
(let ((#:|packages120| (locked-packages 'nil)))
  (unlock-packages #:|packages120|)
  (unwind-protect (lock-packages #:|packages120|)))
Write a Common Lisp macro to handle this code pattern:
(fgather-next nil (progn))

Problem: Macro call that should be transformed by FGATHER-NEXT

Macro definition:
(defmacro FGATHER-NEXT ...)

Macroexpansion:
(nil (progn) nil)
Write a Common Lisp macro to handle this code pattern:
(defun nil ())

Problem: Macro call that should be transformed by DEFUN

Macro definition:
(defmacro DEFUN ...)

Macroexpansion:
(progn
 (eval-when (:compile-toplevel) (sb-c:%compiler-defun 'nil t nil nil))
 (sb-impl::%defun 'nil
                  (sb-int:named-lambda nil
                      nil
                    (block nil))))