j14i/cl-macros huggingface dataset:
You are a Common Lisp macro expert. Given this code pattern:
(defexpander nil)

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

Macro definition:
(defmacro DEFEXPANDER ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (setf (get 'nil +expander-prop+) (gensym #A((3) base-char . "NIL")))
  (defmethod (setf documentation)
             (#:docstring122 #:sym-obj123 (#:doc-type124 (eql 'nil)))
    (declare (ignore #:doc-type124))
    (setf (expander-info-docstring
           (get #:sym-obj123 (get 'nil +expander-prop+)))
            #:docstring122))
  (defmethod documentation (#:sym-obj123 (#:doc-type124 (eql 'nil)))
    (declare (ignore #:doc-type124))
    (expander-info-docstring (get #:sym-obj123 (get 'nil +expander-prop+))))
  'nil)
You are a Common Lisp macro expert. Given this code pattern:
(defvar-compile-time *local?* nil "This must be globally NIL.")

Write a macro that addresses: Macro call that should be transformed by defvar-compile-time

Macro definition:
(defmacro defvar-compile-time (name &optional initial-value documentation)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (defvar ,name ,initial-value ,documentation)))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (defvar *local?* nil "This must be globally NIL."))
Generate a defmacro form that transforms code like this:
(make-obsolete mustache-compile compile-template "0.10.0")

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

Macro definition:
(defmacro make-obsolete (obsolete-name current-name when)
  `(defun ,obsolete-name (&rest args)
     ,(documentation current-name 'function)
     (warn 'deprecation-warning
           :name ',obsolete-name :replacement ',current-name :since ,when)
     (apply ',current-name args)))

Macroexpansion:
(defun mustache-compile (&rest args) "Return a compiled rendering function." (warn (quote deprecation-warning) :name (quote mustache-compile) :replacement (quote compile-template) :since "0.10.0") (apply (quote compile-template) args))
Create a Common Lisp macro for the following transformation. Before code:
(defguarantee add (&rest addends) "result < 20" (declare (ignore addends)) (< (results) 20))

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

Macro definition:
(defmacro defguarantee (name (&rest lambda-list) &body body)
  "Adds a postcondition to the NAMEd function. It can be either a generic or
   non-generic function. If it's the former, then use a specialized lambda list,
   otherwise use an ordinary lambda list. The docstring, if any, will be used in
   failure reports."
  #+qpq-postcondition-checks-disabled
  (declare (ignore name lambda-list body))
  #+qpq-postcondition-checks-disabled
  (values)
  #-qpq-postcondition-checks-disabled
  (multiple-value-bind (remaining-forms declarations doc-string)
      (parse-body body :documentation t)
    (declare (ignore declarations))
    (let* ((stripped-ll (strip-lambda-list lambda-list))
           (lambda-vars (remove-if (rcurry #'member
                                           '(&optional &rest
                                             &key &allow-other-keys &aux))
                                   stripped-ll))
           (method `(progn
                      (ensure-contracted-function ',name ',stripped-ll)
                      (defmethod ,name
                          :guarantee
                          ,(or doc-string
                            (format nil "~A"
                             (description<-remaining-forms
                              remaining-forms)))
                        ,lambda-list
                        (declare (ignorable ,@lambda-vars))
                        ,@body))))
      (if (every #'symbolp lambda-list)
          `(if (and (fboundp ',name)
                    (not (typep (fdefinition ',name) 'generic-function)))
               (defcontract ,name :guarantee ,lambda-list
                 (declare (ignorable ,@lambda-vars))
                 ,@body)
               ,method)
          method))))

Macroexpansion:
(if (and (fboundp (quote add)) (not (typep (fdefinition (quote add)) (quote generic-function)))) (defcontract add :guarantee (&rest addends) (declare (ignorable addends)) "result < 20" (declare (ignore addends)) (< (results) 20)) (progn (ensure-contracted-function (quote add) (quote (&rest addends))) (defmethod add :guarantee "result < 20" (&rest addends) (declare (ignorable addends)) "result < 20" (declare (ignore addends)) (< (results) 20))))
Create a Common Lisp macro for the following transformation. Before code:
(with-html-string (:tag :name "x-y" "Hello"))

What needs to change: 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 (:tag :name "x-y" "Hello")))
Generate a defmacro form that transforms code like this:
(lexpr-$send nil nil)

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

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

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

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

Macro definition:
(defmacro FGATHERLET ...)

Macroexpansion:
(flet ()
  :key
  nil)
Write a Common Lisp macro to handle this code pattern:
(defjs reduce4(k vals) (return (ps:create :vals vals)))

Problem: Macro call that should be transformed by defjs

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

Macroexpansion:
(let* ((js-body (parenscript:ps (lambda (k vals) (return (parenscript:create :vals vals)))))) (setf (gethash (quote reduce4) *js-definitions*) js-body) (defun reduce4 (k vals) (get-element "retval" (car (docs (db.eval js-body k vals))))))
Generate a defmacro form that transforms code like this:
(def-neo4j-fun delete-relationship (relationship-id) :delete (:uri-spec (format nil "relationship/~A" relationship-id)) (:status-handlers (204 (values t body)) (404 (error 'relationship-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 delete-relationship (&key relationship-id) (let ((uri (format nil "relationship/~A" 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))))))))
Write a Common Lisp macro to handle this code pattern:
(defun nil :key 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
                      :key
                    (block nil nil))))
Generate a defmacro form that transforms code like this:
(dynamic-let nil
  nil)

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

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

Macroexpansion:
(let ()
  (dynamic-wind
    :proceed
    #:g193
    (let ()
      (declare (special))
      (#:g193 nil))))
Write a Common Lisp macro to handle this code pattern:
(destructure-specialized-lambda-list descriptive-lambda-list vanilla-lambda-list type-list specialized-lambda-list `(funcall (dispatch-function (dispatch-for-qualifier ',qualifier)) (list ,@vanilla-lambda-list) (mapcar #'hook-name (specific-hooks-for-generic ',type-list ',generic-function ',qualifier))))

Problem: Macro call that should be transformed by destructure-specialized-lambda-list

Macro definition:
(defmacro destructure-specialized-lambda-list (descriptive-lambda-list-sym vanilla-lambda-list-sym type-list-sym specialized-lambda-list &body body)
  "if specialized-lambda-list is ((a integer) b):
descriptive-lambda-list will be ((x integer) (x t))
type-list will be (integer t) and vanilla-lambda-list is (a b)"
  (let ((item (gensym)))
    `(let* ((,descriptive-lambda-list-sym
             (loop :for ,item :in ,specialized-lambda-list
                :if (listp ,item)
                :collect ,item
                :else :collect (list ,item t)))
            (,vanilla-lambda-list-sym (mapcar #'first ,descriptive-lambda-list-sym))
            (,type-list-sym (mapcar #'second ,descriptive-lambda-list-sym)))
       (declare (ignorable ,descriptive-lambda-list-sym ,vanilla-lambda-list-sym ,type-list-sym))
       ,@body)))

Macroexpansion:
(let* ((descriptive-lambda-list (loop :for #:g124 :in specialized-lambda-list :if (listp #:g124) :collect #:g124 :else :collect (list #:g124 t))) (vanilla-lambda-list (mapcar (function first) descriptive-lambda-list)) (type-list (mapcar (function second) descriptive-lambda-list))) (declare (ignorable descriptive-lambda-list vanilla-lambda-list type-list)) (sb-int:quasiquote (funcall (dispatch-function (dispatch-for-qualifier (quote #S(sb-impl::comma :expr qualifier :kind 0)))) (list #S(sb-impl::comma :expr vanilla-lambda-list :kind 2)) (mapcar (function hook-name) (specific-hooks-for-generic (quote #S(sb-impl::comma :expr type-list :kind 0)) (quote #S(sb-impl::comma :expr generic-function :kind 0)) (quote #S(sb-impl::comma :expr qualifier :kind 0)))))))
Create a Common Lisp macro for the following transformation. Before code:
(with-cached-reader-conditionals
  'some-name)

What needs to change: 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 () 'some-name))
Create a Common Lisp macro for the following transformation. Before code:
(matrix-typecase 'some-name)

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

Macro definition:
(defmacro MATRIX-TYPECASE ...)

Macroexpansion:
(let ((#:g245 quote))
  (typecase #:g245))
Write a Common Lisp macro to handle this code pattern:
(inext-or-error 'some-name)

Problem: Macro call that should be transformed by INEXT-OR-ERROR

Macro definition:
(defmacro INEXT-OR-ERROR ...)

Macroexpansion:
(let ((vals (multiple-value-list (funcall (i-coro 'some-name) nil))))
  (if (not vals)
      (error 'stop-iteration)
      (values (car vals) t)))
Define a macro that eliminates this repetitive pattern:
(define-direct-binding = (var form &key then) (let* ((undef '#.(gensym "UNDEF")) (vars (loop for var in (lambda-fiddle:extract-lambda-vars (enlist var)) collect `(,var ',undef)))) (if then (values `(let ,vars) `(if (eq ,(caar vars) ,undef) (update ,var ,form) (update ,var ,then))) (values `(let ,vars) `(update ,var ,form)))))

Issue: Macro call that should be transformed by define-direct-binding

Macro definition:
(defmacro define-direct-binding (name args &body body)
  (let ((env (or (lambda-fiddle:environment-lambda-var args) (gensym "ENVIRONMENT"))))
    `(progn (setf (binding ',name)
                  (lambda ,(lambda-fiddle:remove-environment-part args)
                    (let ((,env *environment*))
                      (declare (ignorable ,env))
                      ,@body)))
            ',name)))

Macroexpansion:
(progn (setf (binding (quote =)) (lambda (var form &key then) (let ((#:environment130 *environment*)) (declare (ignorable #:environment130)) (let* ((undef (quote #:undef129)) (vars (loop for var in (lambda-fiddle:extract-lambda-vars (enlist var)) collect (sb-int:quasiquote (#S(sb-impl::comma :expr var :kind 0) (quote #S(sb-impl::comma :expr undef :kind 0))))))) (if then (values (sb-int:quasiquote (let #S(sb-impl::comma :expr vars :kind 0))) (sb-int:quasiquote (if (eq #S(sb-impl::comma :expr (caar vars) :kind 0) #S(sb-impl::comma :expr undef :kind 0)) (update #S(sb-impl::comma :expr var :kind 0) #S(sb-impl::comma :expr form :kind 0)) (update #S(sb-impl::comma :expr var :kind 0) #S(sb-impl::comma :expr then :kind 0))))) (values (sb-int:quasiquote (let #S(sb-impl::comma :expr vars :kind 0))) (sb-int:quasiquote (update #S(sb-impl::comma :expr var :kind 0) #S(sb-impl::comma :expr form :kind 0))))))))) (quote =))
Create a Common Lisp macro for the following transformation. Before code:
(defreply nil
    (progn))

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

Macro definition:
(defmacro DEFREPLY ...)

Macroexpansion:
(progn
 (eval-when (:compile-toplevel)
   (unless (fboundp 'nil)
     (warn 'automatic-message-creation :message-name 'nil)
     (ensure-message 'nil :lambda-list '(progn))))
 (ensure-reply 'nil :qualifiers 'nil :lambda-list '(progn) :participants
               (list =t=) :documentation nil :function
               (lambda (#:args140 #:next-replies141 &rest #:more-args143)
                 (declare
                  (ignorable #:args140 #:next-replies141 #:more-args143))
                 (flet ((next-reply-p ()
                          (not (null #:next-replies141)))
                        (call-next-reply (&rest args)
                          (if (null #:next-replies141)
                              (apply 'no-next-reply
                                     (getf #:more-args143 :message)
                                     (getf #:more-args143 :reply)
                                     (or args #:args140))
                              (apply (reply-function (car #:next-replies141))
                                     (or args #:args140)
                                     (cdr #:next-replies141) #:more-args143))))
                   (declare
                    (ignorable (function next-reply-p)
                     (function call-next-reply)))
                   (flet ((#:reply-function142 (progn)
                            (declare (ignorable))
                            (block nil)))
                     (declare (inline #:reply-function142))
                     (apply #'#:reply-function142 #:args140))))))
Write a Common Lisp macro to handle this code pattern:
(defsynonym mult :mult)

Problem: 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 mult) (quote synonym)) (quote :mult)))
Create a Common Lisp macro for the following transformation. Before code:
(answer (foo 2) 3)

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

Macro definition:
(defmacro answer (call &body forms)
  (let ((name (if (listp call) (car call) call))
        (sym (gensym)))
    `(if-called
      ',name
      (let ((,sym (fdefinition ',name)))
        (declare (ignorable ,sym))
        (let ((times 0))
          (lambda (&rest args)
            (declare (ignorable args))
            ,(let ((cases
                     `(case (prog1 times (incf times))
                        ,.(loop
                            for i from 0
                            for (form . rest) on forms
                            collect `(,(if rest i T) ,form)))))
               (if (listp call)
                   `(trivia:match args
                     ((list . ,(cdr call)) ,cases)
                     (_ (unhandled)))
                   cases))))))))

Macroexpansion:
(if-called (quote foo) (let ((#:g161 (fdefinition (quote foo)))) (declare (ignorable #:g161)) (let ((times 0)) (lambda (&rest args) (declare (ignorable args)) (trivia.level2:match args ((list 2) (case (prog1 times (incf times)) (t 3))) (_ (unhandled)))))))
Write a Common Lisp macro to handle this code pattern:
(deferror "40" 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-rollback (database-error) nil) (setf (gethash "40" *error-table*) (quote transaction-rollback)))
Write a Common Lisp macro to handle this code pattern:
(with-html-string (:p :class :foo))

Problem: Macro call that should be transformed by with-html

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

Macroexpansion:
(with-output-to-string (*html*) (with-html (:p :class :foo)))
Define a macro that eliminates this repetitive pattern:
(lambda (quote some-name))

Issue: Macro call that should be transformed by LAMBDA

Macro definition:
(defmacro LAMBDA ...)

Macroexpansion:
#'(lambda (quote some-name))
Generate a defmacro form that transforms code like this:
(the-part nil (progn))

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

Macro definition:
(defmacro THE-PART ...)

Macroexpansion:
(send part nil (progn))
Generate a defmacro form that transforms code like this:
(with-connection (let ((user (retrieve-one :user :by :name := "nitro_idiot" :as 'user))) (is-type (user-created-at user) 'local-time:timestamp) (is (user-updated-at user) nil) (is (user-status user) :normal) (is (length (user-tweets user)) 2) (is (tweet-id (car (user-tweets user :limit 1))) 2) (is (tweet-id (car (user-tweets user :limit 1 :offset 1))) 1) (is (length (user-tweets user :limit 2)) 2) (ok (every (lambda (tweet) (typep tweet 'tweet)) (user-tweets user))) (execute (insert-into :tweet (set= :id 3 :user_id 1 :body "Looks good." :created_at (princ-to-string *now*)))) (is (length (user-tweets user)) 2 "Result cached") (let ((test-val '#:test-val)) (setf (user-tweets user) test-val) (is (user-tweets user) test-val :test #'eq "Set cache value")) (datafly.cache:clear-object-caches user) (is (length (user-tweets user)) 3)))

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

Macro definition:
(defmacro with-connection (&body body)
  `(let ((*connection* (connect-cached :sqlite3 :database-name *db-path*)))
     ,@body))

Macroexpansion:
(let ((let (connect ((user (retrieve-one :user :by :name := "nitro_idiot" :as (quote user)))) (is-type (user-created-at user) (quote local-time:timestamp)) (is (user-updated-at user) nil) (is (user-status user) :normal) (is (length (user-tweets user)) 2) (is (tweet-id (car (user-tweets user :limit 1))) 2) (is (tweet-id (car (user-tweets user :limit 1 :offset 1))) 1) (is (length (user-tweets user :limit 2)) 2) (ok (every (lambda (tweet) (typep tweet (quote tweet))) (user-tweets user))) (execute (insert-into :tweet (set= :id 3 :user_id 1 :body "Looks good." :created_at (princ-to-string *now*)))) (is (length (user-tweets user)) 2 "Result cached") (let ((test-val (quote #:test-val))) (setf (user-tweets user) test-val) (is (user-tweets user) test-val :test (function eq) "Set cache value")) (datafly.cache:clear-object-caches user) (is (length (user-tweets user)) 3)))) (unwind-protect (progn) (disconnect let)))
You are a Common Lisp macro expert. Given this code pattern:
(when (symbolp x) (equal (symbol-name x) (string-upcase symbol)))

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 (symbolp x) (equal (symbol-name x) (string-upcase symbol)))
Define a macro that eliminates this repetitive pattern:
(when name `(make-node ,name))

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 name (sb-int:quasiquote (make-node #S(sb-impl::comma :expr name :kind 0))))
Create a Common Lisp macro for the following transformation. Before code:
(letrec-syntax common-lisp:nil :key common-lisp:nil)

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

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

Macroexpansion:
(common-lisp:macrolet ()
  :key
  common-lisp:nil)
Define a macro that eliminates this repetitive pattern:
(define-bug with-fresh-env-scope-missing-env () () "with-fresh-env-scope expects a code object & an environment to be returned from it's body. However there was no environment returned.")

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

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

Macroexpansion:
(defcondition with-fresh-env-scope-missing-env (:error-type varjo-error :prefix "Varjo Bug") nil "with-fresh-env-scope expects a code object & an environment to be returned from it's body. However there was no environment returned.")
Generate a defmacro form that transforms code like this:
(defsynonym generating :generate)

Pattern to recognize: 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 generating) (quote synonym)) (quote :generate)))
You are a Common Lisp macro expert. Given this code pattern:
(ematch0 args (nil nil) ((list* '&aux rest) args) ((list* (list name) rest) (list* (list name ''_) (process-keyword-args rest))) ((list* (list name default) rest) (list* (list name default) (process-keyword-args rest))) ((list* (list name default pred) rest) (list* (list name default pred) (process-keyword-args rest))) ((list* name rest) (list* (list name ''_) (process-keyword-args rest))))

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

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

Macroexpansion:
(match0 args (nil nil) ((list* (quote &aux) rest) args) ((list* (list name) rest) (list* (list name (quote (quote _))) (process-keyword-args rest))) ((list* (list name default) rest) (list* (list name default) (process-keyword-args rest))) ((list* (list name default pred) rest) (list* (list name default pred) (process-keyword-args rest))) ((list* name rest) (list* (list name (quote (quote _))) (process-keyword-args rest))) (_ (error "level0 match error!")))