j14i/cl-macros huggingface dataset:
Create a Common Lisp macro for the following transformation. Before code:
(define-cruft %unassociate-readtable-from-name (name readtable) "Remove the association between READTABLE and NAME." #+ :common-lisp (progn (assert (eq name (gethash readtable *readtable-names*))) (remhash readtable *readtable-names*)))

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

Macro definition:
(defmacro define-cruft (name lambda-list &body (docstring . alternatives))
  (assert (typep docstring 'string) (docstring) "Docstring missing!")
  (assert (not (null alternatives)))
  `(progn
     (declaim (inline ,name))
     (defun ,name ,lambda-list ,docstring ,(first alternatives))))

Macroexpansion:
(progn (declaim (inline %unassociate-readtable-from-name)) (defun %unassociate-readtable-from-name (name readtable) "Remove the association between READTABLE and NAME." (progn (assert (eq name (gethash readtable *readtable-names*))) (remhash readtable *readtable-names*))))
Create a Common Lisp macro for the following transformation. Before code:
(ignore-errors nil nil)

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

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

Macroexpansion:
(handler-case (progn nil nil) (error (condition) (values nil condition)))
You are a Common Lisp macro expert. Given this code pattern:
(when =pos (setf key (subseq str 0 =pos)) (setf val (string-trim white (subseq str (1+ =pos)))))

Write a macro that addresses: 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 =pos (progn (setf key (subseq str 0 =pos)) (setf val (string-trim white (subseq str (1+ =pos))))))
Define a macro that eliminates this repetitive pattern:
(with-cached-reader-conditionals
  nil
  nil)

Issue: Macro call that should be transformed by WITH-CACHED-READER-CONDITIONALS

Macro definition:
(defmacro WITH-CACHED-READER-CONDITIONALS ...)

Macroexpansion:
(call-with-cached-reader-conditionals (lambda () nil nil))
You are a Common Lisp macro expert. Given this code pattern:
(ps-once-only 'some-name)

Write a macro that addresses: Macro call that should be transformed by PS-ONCE-ONLY

Macro definition:
(defmacro PS-ONCE-ONLY ...)

Macroexpansion:
(let* ((#:quote1 (ps-gensym 'quote)) (#:some-name2 (ps-gensym 'some-name)))
  `(let* (,(list #:quote1 quote) ,(list #:some-name2 some-name))
     ,(let* ((quote #:quote1) (some-name #:some-name2)))))
Define a macro that eliminates this repetitive pattern:
(define _IONBF 3)

Issue: 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 _ionbf) *preprocessor-defines*) #A((1) base-char . "3"))) (defparameter _ionbf 3))
Write a Common Lisp macro to handle this code pattern:
(do+ (for x (from 0 :to 3)) (skip) (collect x))

Problem: Macro call that should be transformed by do+

Macro definition:
(defmacro do+ (&body body)
  "High-level, extensible iteration construct. Refer to the manual for syntax and semantics."
  `(do+/internal nil ,@body))

Macroexpansion:
(do+/internal nil (for x (from 0 :to 3)) (skip) (collect x))
Create a Common Lisp macro for the following transformation. Before code:
(or nil (progn))

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

Macro definition:
(defmacro OR ...)

Macroexpansion:
(let ((#:g202 nil))
  (if #:g202
      #:g202
      (progn)))
You are a Common Lisp macro expert. Given this code pattern:
(define-global-var* nil nil)

Write a macro that addresses: Macro call that should be transformed by DEFINE-GLOBAL-VAR*

Macro definition:
(defmacro DEFINE-GLOBAL-VAR* ...)

Macroexpansion:
(sb-ext:define-load-time-global nil nil)
Define a macro that eliminates this repetitive pattern:
(define-type-alias 'some-name)

Issue: Macro call that should be transformed by DEFINE-TYPE-ALIAS

Macro definition:
(defmacro DEFINE-TYPE-ALIAS ...)

Macroexpansion:
(progn
 (defclass some-name (type-alias)
           ((instances :initform nil :accessor instances :allocation :class)))
 (setf (instances (allocate-instance (find-class 'some-name))) (list))
 (deftype quote () '(or)))
Write a Common Lisp macro to handle this code pattern:
(deferror "40002" transaction-integrity-constraint-violation transaction-rollback)

Problem: 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 transaction-integrity-constraint-violation (transaction-rollback) nil) (setf (gethash "40002" *error-table*) (quote transaction-integrity-constraint-violation)))
Generate a defmacro form that transforms code like this:
(with-special-initargs* nil
  (progn))

Pattern to recognize: Macro call that should be transformed by WITH-SPECIAL-INITARGS*

Macro definition:
(defmacro WITH-SPECIAL-INITARGS* ...)

Macroexpansion:
(progn (progn))
Define a macro that eliminates this repetitive pattern:
(sor (car x) (setf it t))

Issue: Macro call that should be transformed by sor

Macro definition:
(defmacro sor (first &rest rest)
  "Like OR, except binds the first argument to IT (via SYMBOL-MACROLET) for
the scope of the rest of the arguments. IT can be set with SETF."
  `(symbolic or ,first ,@rest))

Macroexpansion:
(symbolic or (car x) (setf it t))
Generate a defmacro form that transforms code like this:
(f_n
  nil
  (progn))

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

Macro definition:
(defmacro F_N ...)

Macroexpansion:
(lambda (&rest _) nil (progn))
Generate a defmacro form that transforms code like this:
(defjs map2() (emit this.k (ps:create :count 1)))

Pattern to recognize: 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 (emit this.k (parenscript:create :count 1)))))) (setf (gethash (quote map2) *js-definitions*) js-body) (defun map2 nil (get-element "retval" (car (docs (db.eval js-body))))))
Create a Common Lisp macro for the following transformation. Before code:
(with-open-temporary-file (f :keep nil) (pathname f))

What needs to change: Macro call that should be transformed by with-open-temporary-file

Macro definition:
(defmacro with-open-temporary-file ((stream &rest args &key keep &allow-other-keys) &body body)
  "Create a temporary file using OPEN-TEMPORARY with ARGS and run BODY
  with STREAM bound to the temporary file stream.  Returns the values
  returned by BODY.  By default, the file is deleted when BODY is
  exited. If a true value is passed in KEEP, the file is not deleted
  when the body is exited.  See OPEN-TEMPORARY for more permitted
  options."
  `(with-open-stream (,stream (open-temporary ,@(alexandria:remove-from-plist args :keep)))
     #+sbcl
     (declare (sb-ext:muffle-conditions sb-ext:code-deletion-note))
     ,(if (and (constantp keep)
               keep)
          `(progn ,@body)
          `(unwind-protect
                (progn ,@body)
             (unless ,keep
               (close ,stream)
               (delete-file (pathname ,stream)))))))

Macroexpansion:
(with-open-stream (f (open-temporary)) (declare (sb-ext:muffle-conditions sb-ext:code-deletion-note)) (unwind-protect (progn (pathname f)) (unless nil (close f) (delete-file (pathname f)))))
Create a Common Lisp macro for the following transformation. Before code:
(undef$method 'some-name)

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

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

Macroexpansion:
(undefmethod 'some-name)
Define a macro that eliminates this repetitive pattern:
(define-simple-definition-resolver alien-type (designator) (sb-int:info :alien-type :definition designator))

Issue: 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 alien-type (alien-type #:package148) (when (ignore-errors (let ((designator alien-type)) (sb-int:info :alien-type :definition designator))) (list (make-instance (quote alien-type) :designator alien-type :package #:package148))))
Write a Common Lisp macro to handle this code pattern:
(unwind-protect-case (aborted-p) (return-from foof) (:always (setq result aborted-p)))

Problem: 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+128 t)) (unwind-protect (multiple-value-prog1 (return-from foof) (setf #:flag+128 nil)) (let ((aborted-p #:flag+128)) (progn (setq result aborted-p)))))
Define a macro that eliminates this repetitive pattern:
(with-additional-indent (reporter stream "~& ") (with-color (:green :stream stream) (with-additional-indent (reporter stream "✓ ") (let ((description (possible-report-description report)) (duration (slot-value report 'duration))) (when description (with-color (:gray :stream stream) (format/indent reporter stream description))) (when duration (format stream " ") (print-duration stream duration (slot-value report 'slow-threshold)))) (terpri stream))))

Issue: Macro call that should be transformed by with-additional-indent

Macro definition:
(defmacro with-additional-indent ((reporter stream control-string &rest format-arguments) &body body)
  (declare (ignorable reporter stream control-string))
  (let* ((need-new-line (ppcre:scan "^~&" control-string))
         (string (apply #'format nil control-string format-arguments))
         (increment (length string)))
    `(with-slots (indent-space) reporter
       (let* ((first-line-indent (indent indent-space))
              (*additional-indent* ,(if need-new-line
                                        increment
                                        `(+ *additional-indent*
                                            ,increment))))
         (declare (ignorable first-line-indent))
         ,(if need-new-line
              `(progn (fresh-line stream)
                      (write-string first-line-indent ,stream)
                      ;; because we just started a new line, we
                      ;; should use format/indent to write string
                      ;; taking into account a main indentation level
                      (format/indent ,reporter ,stream ,string))
              ;; otherwise, just output our prefix
              `(write-string ,string ,stream))
       
       
         ,@body))))

Macroexpansion:
(with-slots (indent-space) reporter (let* ((first-line-indent (indent indent-space)) (*additional-indent* 1)) (declare (ignorable first-line-indent)) (progn (fresh-line stream) (write-string first-line-indent stream) (format/indent reporter stream #A((1) base-char . " "))) (with-color (:green :stream stream) (with-additional-indent (reporter stream "✓ ") (let ((description (possible-report-description report)) (duration (slot-value report (quote duration)))) (when description (with-color (:gray :stream stream) (format/indent reporter stream description))) (when duration (format stream " ") (print-duration stream duration (slot-value report (quote slow-threshold))))) (terpri stream)))))
Define a macro that eliminates this repetitive pattern:
(c-assert rsibs () "find-prior > fpsib > self ~s not found to prior off" self)

Issue: 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 rsibs (c-break "find-prior > fpsib > self ~s not found to prior off" self)))
Write a Common Lisp macro to handle this code pattern:
(def-neo4j-fun del-relationship-properties (relationship-id) :delete (:uri-spec (format nil "relationship/~A/properties" relationship-id)) (:status-handlers (204 (values t body)) (404 (error 'relationship-not-found-error :uri uri))))

Problem: 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-relationship-properties (&key relationship-id) (let ((uri (format nil "relationship/~A/properties" relationship-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 relationship-not-found-error) :uri uri))))))))
Generate a defmacro form that transforms code like this:
(with-prepared-query query (conn (format nil "SELECT column_name FROM information_schema.columns WHERE table_name = '~A'" table-name)) (mapcar #'car (dbi:fetch-all (dbi:execute query) :format :values)))

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

Macro definition:
(defmacro with-prepared-query (query (conn sql &key use-prepare-cached) &body body)
  `(call-with-prepared-query ,conn ,sql (lambda (,query) ,@body) :use-prepare-cached ,use-prepare-cached))

Macroexpansion:
(call-with-prepared-query conn (format nil "SELECT column_name FROM information_schema.columns WHERE table_name = '~A'" table-name) (lambda (query) (mapcar (function car) (dbi.driver:fetch-all (dbi.driver:execute query) :format :values))) :use-prepare-cached nil)
Generate a defmacro form that transforms code like this:
(dynamic-reprogv nil
    (progn))

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

Macro definition:
(defmacro DYNAMIC-REPROGV ...)

Macroexpansion:
(dynamic-wind
  :proceed
  #:proceed201
  (let* ((#:computed-symbols199 nil)
         (#:computed-bindings200
          (compute-bindings #:computed-symbols199 (progn))))
    (progv #:computed-symbols199 #:computed-bindings200 (#:proceed201))))
You are a Common Lisp macro expert. Given this code pattern:
(is-false nil)

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

Macro definition:
(defmacro is-false (condition &rest reason-args)
  "Generates a pass if CONDITION returns false, generates a
  failure otherwise. Like IS-TRUE, and unlike IS, IS-FALSE does
  not inspect CONDITION to determine what reason to give it case
  of test failure"
  (with-gensyms (value)
    `(let ((,value ,condition))
       (if ,value
           (process-failure ',condition
                            ,@(or reason-args
                                  `("~S returned the value ~S, which is true" ',condition ,value)))
           (add-result 'test-passed :test-expr ',condition)))))

Macroexpansion:
(let ((#:value283 nil)) (if #:value283 (process-failure (quote nil) "~S returned the value ~S, which is true" (quote nil) #:value283) (add-result (quote test-passed) :test-expr (quote nil))))
Generate a defmacro form that transforms code like this:
(defun/1 puts (str) (when (eql EOF (fputs str stdout)) (return-from puts EOF)) (when (eql EOF (fputc #\Newline stdout)) (return-from puts EOF)) 0)

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 puts (str) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (when (eql eof (fputs str stdout)) (return-from puts eof)) (when (eql eof (fputc #\Newline stdout)) (return-from puts eof)) 0) (defparameter puts (vacietis.c:mkptr& (symbol-function (quote puts)))))
Write a Common Lisp macro to handle this code pattern:
(without-dependency-capture
  nil)

Problem: Macro call that should be transformed by WITHOUT-DEPENDENCY-CAPTURE

Macro definition:
(defmacro WITHOUT-DEPENDENCY-CAPTURE ...)

Macroexpansion:
(let ((%dependent% nil))
  nil)
Generate a defmacro form that transforms code like this:
(ps-package-prefix nil)

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

Macro definition:
(defmacro PS-PACKAGE-PREFIX ...)

Macroexpansion:
(gethash (find-package nil) *package-prefix-table*)
Create a Common Lisp macro for the following transformation. Before code:
(define-simple-clause returning (form) (values NIL form))

What needs to change: 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 returning (form) (let nil (values* (sb-int:quasiquote (let* #S(sb-impl::comma :expr (list) :kind 0) (declare (ignorable)))) (let nil (declare (ignorable)) (values nil form)))))
You are a Common Lisp macro expert. Given this code pattern:
(defjs reduce3(k vals) (return (length (aref vals 0))))

Write a macro that addresses: 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 (k vals) (return (length (aref vals 0))))))) (setf (gethash (quote reduce3) *js-definitions*) js-body) (defun reduce3 (k vals) (get-element "retval" (car (docs (db.eval js-body k vals))))))
Write a Common Lisp macro to handle this code pattern:
(is-false t)

Problem: Macro call that should be transformed by is-false

Macro definition:
(defmacro is-false (condition &rest reason-args)
  "Generates a pass if CONDITION returns false, generates a
  failure otherwise. Like IS-TRUE, and unlike IS, IS-FALSE does
  not inspect CONDITION to determine what reason to give it case
  of test failure"
  (with-gensyms (value)
    `(let ((,value ,condition))
       (if ,value
           (process-failure ',condition
                            ,@(or reason-args
                                  `("~S returned the value ~S, which is true" ',condition ,value)))
           (add-result 'test-passed :test-expr ',condition)))))

Macroexpansion:
(let ((#:value284 t)) (if #:value284 (process-failure (quote t) "~S returned the value ~S, which is true" (quote t) #:value284) (add-result (quote test-passed) :test-expr (quote t))))
Create a Common Lisp macro for the following transformation. Before code:
(ensure-gethash (car cons) table (cdr cons))

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

Macro definition:
(defmacro ensure-gethash (key hash-table &optional default)
  "Like GETHASH, but if KEY is not found in the HASH-TABLE saves the DEFAULT
under key before returning it. Secondary return value is true if key was
already in the table."
  (once-only (key hash-table)
    (with-unique-names (value presentp)
      `(multiple-value-bind (,value ,presentp) (gethash ,key ,hash-table)
         (if ,presentp
             (values ,value ,presentp)
             (values (setf (gethash ,key ,hash-table) ,default) nil))))))

Macroexpansion:
(let ((#:n-key-151 (car cons)) (#:n-hash-table-152 table)) (multiple-value-bind (#:value153 #:foundp154) (gethash #:n-key-151 #:n-hash-table-152) (if #:foundp154 (values #:value153 t) (values (setf (gethash #:n-key-151 #:n-hash-table-152) (cdr cons)) nil))))