j14i/cl-macros huggingface dataset:
Define a macro that eliminates this repetitive pattern:
(with-input-from-file (stream pathname :element-type '(unsigned-byte 8)) (read-stream-content-into-byte-vector stream :initial-size (file-length stream)))

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* (stream pathname :direction :input :element-type (quote (unsigned-byte 8))) (read-stream-content-into-byte-vector stream :initial-size (file-length stream)))
Generate a defmacro form that transforms code like this:
(-> nil (value) (1+ value))

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

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

Macroexpansion:
(atomically nil (value) (1+ value))
Create a Common Lisp macro for the following transformation. Before code:
(deferror "08000" connection-exception)

What needs to change: 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 connection-exception (database-error) nil) (setf (gethash "08000" *error-table*) (quote connection-exception)))
Generate a defmacro form that transforms code like this:
(do-readtable ((char reader-fn non-terminating-p disp? table) from) (check-reader-macro-conflict from to char) (cond ((not disp?) (set-macro-character char reader-fn non-terminating-p to)) (t (ensure-dispatch-macro-character char non-terminating-p to) (loop for (subchar . subfn) in table do (check-reader-macro-conflict from to char subchar) (set-dispatch-macro-character char subchar subfn to)))))

Pattern to recognize: Macro call that should be transformed by do-readtable

Macro definition:
(defmacro do-readtable ((entry-designator readtable &optional result)
                        &body body)
  "Iterate through a readtable's macro characters, and dispatch macro characters."
  (destructuring-bind (char &optional reader-fn non-terminating-p disp? table)
      (if (symbolp entry-designator)
          (list entry-designator)
          entry-designator)
    (let ((iter (gensym "ITER+"))
          (more? (gensym "MORE?+"))
          (rt (gensym "READTABLE+")))
      `(let ((,rt ,readtable))
         (with-readtable-iterator (,iter ,rt)
           (loop
             (multiple-value-bind (,more?
                                   ,char
                                   ,@(when reader-fn (list reader-fn))
                                   ,@(when disp? (list disp?))
                                   ,@(when table (list table)))
                 (,iter)
               (unless ,more? (return ,result))
               (let ,(when non-terminating-p
                       ;; FIXME: N-T-P should be incorporated in iterators.
                       `((,non-terminating-p
                          (nth-value 1 (get-macro-character ,char ,rt)))))
                 ,@body))))))))

Macroexpansion:
(let ((#:readtable+149 from)) (with-readtable-iterator (#:iter+147 #:readtable+149) (loop (multiple-value-bind (#:more?+148 char reader-fn disp? table) (#:iter+147) (unless #:more?+148 (return nil)) (let ((non-terminating-p (nth-value 1 (get-macro-character char #:readtable+149)))) (check-reader-macro-conflict from to char) (cond ((not disp?) (set-macro-character char reader-fn non-terminating-p to)) (t (ensure-dispatch-macro-character char non-terminating-p to) (loop for (subchar . subfn) in table do (check-reader-macro-conflict from to char subchar) (set-dispatch-macro-character char subchar subfn to)))))))))
Write a Common Lisp macro to handle this code pattern:
(-> :g (r) (put r))

Problem: Macro call that should be transformed by ->

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

Macroexpansion:
(atomically :g (r) (put r))
Write a Common Lisp macro to handle this code pattern:
(-<>> nil nil)

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

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

Macroexpansion:
(nil)
You are a Common Lisp macro expert. Given this code pattern:
(lambda-ignoring-_ (kwd id _l decl _r) (make-struct-or-union-spec :type kwd :id id :struct-decl-list decl))

Write a macro that addresses: 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 id _l decl _r) (declare (ignore _l _r)) (make-struct-or-union-spec :type kwd :id id :struct-decl-list decl))
Create a Common Lisp macro for the following transformation. Before code:
(define-test override (true T) (skip "Not ready yet" (false T) (is = 5 6)) (with-forced-status (:failed) (false NIL)))

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

Macro definition:
(defmacro define-test (name &body arguments-and-body)
  (destructuring-bind (nparent name) (if (listp name) name (list NIL name))
    (form-fiddle:with-body-options (body options parent home (test-class 'test) (compile-at :compile-time) defun) arguments-and-body
      (let ((body (remove 'define-test body :key (lambda (a) (when (listp a) (car a))) :test #'eql))
            (defs (remove 'define-test body :key (lambda (a) (when (listp a) (car a))) :test-not #'eql))
            (home-form (or home `(find-package ,(package-name *package*)))))
        (when (and parent nparent)
          (error "Cannot specify parent through name and through a keyword argument at the same time!"))
        `(let ((*package* (find-package ,(package-name *package*)))) ; Make sure package stays consistent throughout initialisation.
           (setf (find-test ',name ,home-form)
                 (ensure-test ',test-class
                              :name ',name
                              :home ,home-form
                              :tests (list ,@(loop for form in body
                                                   collect (ecase compile-at
                                                             (:compile-time `(lambda () ,form))
                                                             (:execute `(lambda () (call-compile ',form))))))
                              :parent ',(or parent nparent)
                              ,@(loop for option in options
                                      collect `',option)))
           ,@(loop for (def subname . body) in defs
                   collect `(,def (,name ,subname)
                              :home ,home
                              ,@body))
           ,@(when defun
               `((defun ,(if (stringp name) (read-symbol name) name) (&rest test-args)
                   (apply #'test (find-test ',name ,home-form) test-args))))
           ',name)))))

Macroexpansion:
(let ((*package* (find-package #A((9) base-char . "PARACHUTE")))) (setf (find-test (quote override) (find-package #A((9) base-char . "PARACHUTE"))) (ensure-test (quote test) :name (quote override) :home (find-package #A((9) base-char . "PARACHUTE")) :tests (list (lambda nil (true t)) (lambda nil (skip "Not ready yet" (false t) (is = 5 6))) (lambda nil (with-forced-status (:failed) (false nil)))) :parent (quote nil))) (quote override))
Create a Common Lisp macro for the following transformation. Before code:
(define-declaration nil
    :key
  nil)

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

Macro definition:
(defmacro DEFINE-DECLARATION ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (proclaim '(declaration nil))
  (flet ((sb-cltl2::func :key
           nil))
    (setf (sb-int:info :declaration :known 'nil)
            (lambda
                (sb-kernel:lexenv sb-cltl2::spec sb-cltl2::pd-vars
                 sb-cltl2::pd-fvars)
              (multiple-value-bind (sb-cltl2::kind sb-cltl2::data)
                  (sb-cltl2::func sb-cltl2::spec sb-kernel:lexenv)
                (sb-cltl2::update-lexenv-user-data sb-kernel:lexenv
                                                   sb-cltl2::kind
                                                   sb-cltl2::data
                                                   sb-cltl2::pd-vars
                                                   sb-cltl2::pd-fvars))))))
Generate a defmacro form that transforms code like this:
(make-stream-method pp-xml-attr (s (kw string) &optional colon-p at-p) (declare (ignore colon-p at-p)) (format s "~A" kw))

Pattern to recognize: Macro call that should be transformed by make-stream-method

Macro definition:
(defmacro make-stream-method (name (s &rest args) &body body)
  `(progn
     (defmethod ,name ((,s stream) ,@args)
       ,@body)
     #+abcl
     (defmethod ,name ((,s xp::xp-structure) ,@args)
       ,@body)))

Macroexpansion:
(progn (defmethod pp-xml-attr ((s stream) (kw string) &optional colon-p at-p) (declare (ignore colon-p at-p)) (format s "~A" kw)))
Generate a defmacro form that transforms code like this:
(->> nil nil)

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

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

Macroexpansion:
(nil)
Create a Common Lisp macro for the following transformation. Before code:
(action (:after node-lisp node new-subs) (multiple-value-bind (let-bindings lisp-var-bindings) (loop :for (lisp-var . coalton-var) :in (node-lisp-vars node) :for new-var := (gensym (symbol-name coalton-var)) :for res := (or (find coalton-var subs :key #'ast-substitution-from) (find coalton-var new-subs :key #'ast-substitution-from)) :if (and res (node-variable-p (ast-substitution-to res))) :collect (cons lisp-var (node-variable-value (ast-substitution-to res))) :into lisp-var-bindings :else :if res :collect (cons lisp-var new-var) :into lisp-var-bindings :and :collect (cons new-var (ast-substitution-to res)) :into let-bindings :else :collect (cons lisp-var coalton-var) :into lisp-var-bindings :finally (return (values let-bindings lisp-var-bindings))) (let ((new-lisp-node (make-node-lisp :type (node-type node) :vars lisp-var-bindings :form (node-lisp-form node)))) (if (endp let-bindings) new-lisp-node (make-node-let :type (node-type node) :bindings let-bindings :subexpr new-lisp-node)))))

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

Macro definition:
(defmacro action ((when type &rest args) &body body)
  "Construct an action block, turning `body` into a lambda function
accepting `args` if `args` are provided. If there are no `args`, then
`body` is assumed to be a function object and is used directly with
`when` and `type` to create an `action` instance. Otherwise, the first
argument in `args` is declared to be a node of type `type`, and the
`args` and `body` are used to generate a lambda function."
  (check-type when keyword)
  (check-type type symbol)
  (assert (subtypep type 'node))
  (assert (or (not (endp args)) (= 1 (length body))))
  (if (endp args)
      `(make-action ',when ',type ,@body)
      `(make-action ',when ',type
                    (lambda (,@args)
                      (declare (type ,type ,(first args)))
                      ,@body))))

Macroexpansion:
(make-action (quote :after) (quote node-lisp) (lambda (node new-subs) (declare (type node-lisp node)) (multiple-value-bind (let-bindings lisp-var-bindings) (loop :for (lisp-var . coalton-var) :in (node-lisp-vars node) :for new-var := (gensym (symbol-name coalton-var)) :for res := (or (find coalton-var subs :key (function ast-substitution-from)) (find coalton-var new-subs :key (function ast-substitution-from))) :if (and res (node-variable-p (ast-substitution-to res))) :collect (cons lisp-var (node-variable-value (ast-substitution-to res))) :into lisp-var-bindings :else :if res :collect (cons lisp-var new-var) :into lisp-var-bindings :and :collect (cons new-var (ast-substitution-to res)) :into let-bindings :else :collect (cons lisp-var coalton-var) :into lisp-var-bindings :finally (return (values let-bindings lisp-var-bindings))) (let ((new-lisp-node (make-node-lisp :type (node-type node) :vars lisp-var-bindings :form (node-lisp-form node)))) (if (endp let-bindings) new-lisp-node (make-node-let :type (node-type node) :bindings let-bindings :subexpr new-lisp-node))))))
You are a Common Lisp macro expert. Given this code pattern:
(with-html-string (:a :href "#" :data-instant t))

Write a macro that addresses: 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 (:a :href "#" :data-instant t)))
You are a Common Lisp macro expert. Given this code pattern:
(collect 'some-name)

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

Macro definition:
(defmacro COLLECT ...)

Macroexpansion:
(common-lisp:let* ((#:generator-608 (generator 'some-name))
                   #:items-603
                   (#:lastcons-604 (list nil))
                   (#:lst-605 #:lastcons-604))
  (declare (type generator #:generator-608)
           (type cons #:lastcons-604)
           (type list #:lst-605))
  (tagbody
   #:ll-609
    (setq #:items-603 (next-in #:generator-608 (go end)))
    (setq #:lastcons-604 (setf (cdr #:lastcons-604) (cons #:items-603 nil)))
    (go #:ll-609)
   end)
  (cdr #:lst-605))
You are a Common Lisp macro expert. Given this code pattern:
(define-simple-clause never (form &aux (result T)) (values `(when ,form (setf ,result NIL) (end-for)) result))

Write a macro that addresses: Macro call that should be transformed by define-simple-clause

Macro definition:
(defmacro define-simple-clause (name args &body body)
  (multiple-value-bind (args outer-let inner-let result-let) (compute-binding-parts NIL NIL args)
    `(define-direct-clause ,name ,(rest args)
       (let ,outer-let
         (values* `(let* ,(list
                           ,@result-let)
                     (declare (ignorable ,,@(mapcar #'delist outer-let))))
                  (let ,inner-let
                    (declare (ignorable ,@(mapcar #'delist inner-let)))
                    ,@body))))))

Macroexpansion:
(define-direct-clause never (form) (let ((#:result187 (gensym #A((6) base-char . "RESULT")))) (values* (sb-int:quasiquote (let* #S(sb-impl::comma :expr (list (list #:result187 (quote t))) :kind 0) (declare (ignorable #S(sb-impl::comma :expr #:result187 :kind 0))))) (let ((result #:result187)) (declare (ignorable result)) (values (sb-int:quasiquote (when #S(sb-impl::comma :expr form :kind 0) (setf #S(sb-impl::comma :expr result :kind 0) nil) (end-for))) result)))))
Define a macro that eliminates this repetitive pattern:
(with-c-compilation-unit () (parse-with-lexer lexer *c-parser*))

Issue: Macro call that should be transformed by with-c-compilation-unit

Macro definition:
(defmacro with-c-compilation-unit ((&key return-last-statement)
				   &body body)
  "Establishes variable bindings for a new compilation."
  `(let ((*struct-specs* (copy-hash-table *struct-specs*))
         (*typedef-names* (copy-hash-table *typedef-names*))
	 (*return-last-statement* ,return-last-statement)
         (*function-pointer-ids* nil))
     ,@body))

Macroexpansion:
(let ((*struct-specs* (copy-hash-table *struct-specs*)) (*typedef-names* (copy-hash-table *typedef-names*)) (*return-last-statement* nil) (*function-pointer-ids* nil)) (parse-with-lexer lexer *c-parser*))
Generate a defmacro form that transforms code like this:
($send nil nil)

Pattern to recognize: Macro call that should be transformed by $SEND

Macro definition:
(defmacro $SEND ...)

Macroexpansion:
(send-message nil nil)
You are a Common Lisp macro expert. Given this code pattern:
(with-component-testers (a b #'pathname-directory) (and (null a) (null b)) (and (= (length a) (length b)) (every (lambda (a b) (or (and (stringp a) (stringp b) (string= a b)) (and (null a) (null b)) (and (keywordp a) (keywordp b) (eql a b)))) a b)))

Write a macro that addresses: Macro call that should be transformed by with-component-testers

Macro definition:
(defmacro with-component-testers ((a b key) &body body)
  (let ((k (gensym)))
    `(let* ((,k ,key)
            (,a (funcall ,k ,a))
            (,b (funcall ,k ,b)))
       (labels ((components-are (test)
                  (and (funcall test ,a) (funcall test ,b)))
                (components-are-member (values)
                  (and (member ,a values :test #'eql)
                       (member ,b values :test #'eql)
                       (eql ,a ,b)))
                (components-are-string= ()
                  (and (stringp ,a) (stringp ,b) (string= ,a ,b)))
                (components-are-every (test)
                  (and (consp ,a)
                       (consp ,b)
                       (every test ,a ,b))))
         (declare (ignorable #'components-are #'components-are-member
                             #'components-are-string= #'components-are-every))
         (if (or ,@body)
             (values t ,a ,b)
             nil)))))

Macroexpansion:
(let* ((#:g145 (function pathname-directory)) (a (funcall #:g145 a)) (b (funcall #:g145 b))) (labels ((components-are (test) (and (funcall test a) (funcall test b))) (components-are-member (values) (and (member a values :test (function eql)) (member b values :test (function eql)) (eql a b))) (components-are-string= nil (and (stringp a) (stringp b) (string= a b))) (components-are-every (test) (and (consp a) (consp b) (every test a b)))) (declare (ignorable (function components-are) (function components-are-member) (function components-are-string=) (function components-are-every))) (if (or (and (null a) (null b)) (and (= (length a) (length b)) (every (lambda (a b) (or (and (stringp a) (stringp b) (string= a b)) (and (null a) (null b)) (and (keywordp a) (keywordp b) (eql a b)))) a b))) (values t a b) nil)))
Create a Common Lisp macro for the following transformation. Before code:
(c-assert (c-model c) () "c-awaken sees uninstalled cell" c)

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

Macro definition:
(defmacro c-assert (assertion &optional places fmt$ &rest fmt-args)
  (declare (ignorable assertion places fmt$ fmt-args))
   #+(or)`(progn) 
  `(unless *stop*
     (unless ,assertion
       ,(if fmt$
            `(c-break ,fmt$ ,@fmt-args)
          `(c-break "failed assertion: ~a" ',assertion)))))

Macroexpansion:
(unless *stop* (unless (c-model c) (c-break "c-awaken sees uninstalled cell" c)))
Define a macro that eliminates this repetitive pattern:
(defsynonym generate :generate)

Issue: 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 generate) (quote synonym)) (quote :generate)))
You are a Common Lisp macro expert. Given this code pattern:
(cond->> nil :key nil)

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

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

Macroexpansion:
(let* ((#:g136 nil))
  (if :key
      (->> #:g136 nil)
      #:g136))
Write a Common Lisp macro to handle this code pattern:
(dflet ((foo () 23)) (is (eql 23 (foo))))

Problem: Macro call that should be transformed by dflet

Macro definition:
(defmacro dflet ((&rest definitions) &body body)
  "Like FLET, but dynamically sets the FDEFINITIONS during the duration of
the BODY."
  `(progf
       ',(mapcar #'car definitions)
       (list
        ,.(mapcar (lambda (definition)
                    `(lambda ,(cadr definition)
                       ,@(cddr definition)))
                  definitions))
     ,@body))

Macroexpansion:
(progf (quote (foo)) (list (lambda nil 23)) (is (eql 23 (foo))))
Define a macro that eliminates this repetitive pattern:
(return)

Issue: Macro call that should be transformed by RETURN

Macro definition:
(defmacro RETURN ...)

Macroexpansion:
(return-from nil nil)
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* ((#:|some121| nil) (#:|some121| (when #:|some121| (#:|some121|))))
  #:|some121|)
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)
  "Cf. `lret'."
  `(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)
Write a Common Lisp macro to handle this code pattern:
(-> :p () 1)

Problem: Macro call that should be transformed by ->

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

Macroexpansion:
(atomically :p nil 1)
Define a macro that eliminates this repetitive pattern:
(match 1 (1 1))

Issue: 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:
(let ((#:var148 1)) (declare (ignorable #:var148)) (%or (%if (%equals #:var148 1) (%or 1 (fail)) (fail)) nil))