[User]
Define a macro that eliminates this repetitive pattern:
(regex-apropos-aux (regex packages case-insensitive) (print-symbol-info symbol))

Issue: Macro call that should be transformed by regex-apropos-aux

(regex-apropos-aux (regex packages case-insensitive) (print-symbol-info symbol))

[Assistant]
(defmacro regex-apropos-aux ((regex packages case-insensitive &optional return-form)
                             &body body)
  "Auxiliary macro used by REGEX-APROPOS and REGEX-APROPOS-LIST.
Loops through PACKAGES and executes BODY with SYMBOL bound to each
symbol which matches REGEX.  Optionally evaluates and returns
RETURN-FORM at the end.  If CASE-INSENSITIVE is true and REGEX isn't
already a scanner, a case-insensitive scanner is used."
  (with-rebinding (regex)
    (with-unique-names (scanner %packages hash)
      `(let* ((,scanner (create-scanner ,regex
                         :case-insensitive-mode
                         (and ,case-insensitive
                              (not (functionp ,regex)))))
              (,%packages (or ,packages
                             (list-all-packages)))
              (,hash (make-hash-table :test #'eq)))
        (do-with-all-symbols (symbol ,%packages)
          (unless (gethash symbol ,hash)
            (when (scan ,scanner (symbol-name symbol))
              (setf (gethash symbol ,hash) t)
              ,@body)))
        ,return-form))))

;; macroexpand:
(let ((#:regex149 regex)) (let* ((#:scanner150 (create-scanner #:regex149 :case-insensitive-mode (and case-insensitive (not (functionp #:regex149))))) (#:%packages151 (or packages (list-all-packages))) (#:hash154 (make-hash-table :test (function eq)))) (with-package-iterator (#:next152 #:%packages151 :external :internal :inherited) (loop (multiple-value-bind (#:morep153 symbol) (#:next152) (unless #:morep153 (return nil)) (unless (gethash symbol #:hash154) (when (scan #:scanner150 (symbol-name symbol)) (setf (gethash symbol #:hash154) t) (print-symbol-info symbol))))))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(sum-of nil
  nil)

Write a macro that addresses: Macro call that should be transformed by SUM-OF

(sum-of nil
  nil)

[Assistant]
(defmacro SUM-OF ...)

;; macroexpand:
(lc (nil nil) sum)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(is-print (princ "ABCDEFGH") "ABCDEFGHIJKLMNO")

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

(is-print (princ "ABCDEFGH") "ABCDEFGHIJKLMNO")

[Assistant]
(defmacro is (got expected &rest args)
  (with-gensyms (duration result new-args desc)
    (once-only (expected)
      `(let* ((,new-args (list ,@args))
              (,desc (parse-description-and-test ,new-args)))
         (with-catching-errors (:description ,desc :expected ,expected)
           (with-duration ((,duration ,result) ,got)
             (test ,result ,expected ,new-args
                   :duration ,duration)))))))

;; macroexpand:
(let ((#:expected175 "ABCDEFGHIJKLMNO") (#:desc176 nil)) (with-catching-errors (:description #:desc176 :expected #:expected175) (let* (#:duration173 (#:output172 (with-output-to-string (*standard-output*) (with-duration ((#:duration-inner174 #:output172) (princ "ABCDEFGH")) (declare (ignore #:output172)) (setq #:duration173 #:duration-inner174))))) (test #:output172 #:expected175 #:desc176 :duration #:duration173 :got-form (quote (princ "ABCDEFGH")) :test-fn (function string=) :report-expected-label "output"))))


[User]
Write a Common Lisp macro to handle this code pattern:
(sunless x (setf it :oops))

Problem: Macro call that should be transformed by sunless

(sunless x (setf it :oops))

[Assistant]
(defmacro sunless (test &body body)
  "Like UNLESS, except binds the test form to IT (via SYMBOL-MACROLET) for the
scope of the body. IT can be set with SETF."
  `(symbolic unless ,test ,@body))

;; macroexpand:
(symbolic unless x (setf it :oops))


[User]
Write a Common Lisp macro to handle this code pattern:
(defgeneric nil nil)

Problem: Macro call that should be transformed by DEFGENERIC

(defgeneric nil nil)

[Assistant]
(defmacro DEFGENERIC ...)

;; macroexpand:
(common-lisp:defgeneric nil
    nil)


[User]
Generate a defmacro form that transforms code like this:
(define-shell-component sass :input-type "scss" :output-type "css" :shell-command "sass")

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

(define-shell-component sass :input-type "scss" :output-type "css" :shell-command "sass")

[Assistant]
(defmacro define-shell-component (name &key input-type output-type shell-command)
  "Define an ASDF component that's compiled by running a shell command."
  `(define-component ,name
     :input-type ,input-type
     :output-type ,output-type
     :compile-function (lambda (input-pathname output-pathname)
                         (inferior-shell:run (list ,@(ensure-list shell-command)
                                                    input-pathname
                                                    output-pathname)
                                             :show t))))

;; macroexpand:
(define-component sass :input-type "scss" :output-type "css" :compile-function (lambda (input-pathname output-pathname) (inferior-shell:run (list "sass" input-pathname output-pathname) :show t)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(define-simple-error-for sffi-continuable-error)

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

(define-simple-error-for sffi-continuable-error)

[Assistant]
(defmacro define-simple-error-for (base-type &key name object-initarg)
  "Define a simple error subclassing from BASE-TYPE and a corresponding
function, analogous to ERROR, but also optionally taking the object
against which to err, and passing it to ERROR via the OBJECT-INITARG
keyword. The name of the simple error is constructed by prepending
'SIMPLE-' to BASE-TYPE.
Whether or not the error signaller will require and pass the
object is specified by OBJECT-INITARG being non-NIL."
  `(define-simple-condition-for ,base-type :object-initarg ,object-initarg :simple-condition-type simple-error :signaler error
                                ,@(when name `(:name ,name))))

;; macroexpand:
(define-simple-condition-for sffi-continuable-error :object-initarg nil :simple-condition-type simple-error :signaler error)


[User]
Define a macro that eliminates this repetitive pattern:
(quasiquote nil nil)

Issue: Macro call that should be transformed by QUASIQUOTE

(quasiquote nil nil)

[Assistant]
(defmacro QUASIQUOTE ...)

;; macroexpand:
(let ((#:source122 nil))
  (%quote #:source122 'nil))


[User]
Write a Common Lisp macro to handle this code pattern:
(defjs at() (let ((arr (make-array))) (setf (aref arr 0) 10) (setf (aref arr 1) 20) (setf (aref arr 2) 30) (setf (aref arr 4) 40) (setf (aref arr 5) 80) (return (aref arr 2))))

Problem: Macro call that should be transformed by defjs

(defjs at() (let ((arr (make-array))) (setf (aref arr 0) 10) (setf (aref arr 1) 20) (setf (aref arr 2) 30) (setf (aref arr 4) 40) (setf (aref arr 5) 80) (return (aref arr 2))))

[Assistant]
(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)))))))

;; macroexpand:
(let* ((js-body (parenscript:ps (lambda nil (let ((arr (make-array))) (setf (aref arr 0) 10) (setf (aref arr 1) 20) (setf (aref arr 2) 30) (setf (aref arr 4) 40) (setf (aref arr 5) 80) (return (aref arr 2))))))) (setf (gethash (quote at) *js-definitions*) js-body) (defun at nil (get-element "retval" (car (docs (db.eval js-body))))))


[User]
Generate a defmacro form that transforms code like this:
(with-trace-sql (execute-with-retry query binds))

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

(with-trace-sql (execute-with-retry query binds))

[Assistant]
(defmacro with-trace-sql (&body body)
  `(let ((dbi:*sql-execution-hooks* (cons #'trace-sql
                                          dbi:*sql-execution-hooks*)))
     ,@body))

;; macroexpand:
(let ((*sql-execution-hooks* (cons (function trace-sql) *sql-execution-hooks*))) (execute-with-retry query binds))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(assoc-cdr :userinfo--endpoint disc)

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

(assoc-cdr :userinfo--endpoint disc)

[Assistant]
(defmacro assoc-cdr (key alist &optional (test '#'eql))
  `(cdr (assoc ,key ,alist :test ,test)))

;; macroexpand:
(cdr (assoc :userinfo--endpoint disc :test (function eql)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(with-gensyms (num items position not-preceded-by string item new-mode until advancing) `(labels ((advance (,num) (setf ,position-place (+ ,position-place ,num)) t) (peek-any (,items &key ,not-preceded-by) (incf *scan-calls*) (let* ((,items (if (stringp ,items) (coerce ,items 'list) ,items)) (,not-preceded-by (if (characterp ,not-preceded-by) (string ,not-preceded-by) ,not-preceded-by)) (,position ,position-place) (,string ,string-param)) (let ((,item (and (< ,position (length ,string)) (find ,string ,items :test #'(lambda (,string ,item) #+nil (format t "looking for ~S in ~S starting at ~S~%" ,item ,string ,position) (if (characterp ,item) (char= (elt ,string ,position) ,item) (search ,item ,string :start2 ,position :end2 (min (length ,string) (+ ,position (length ,item)))))))))) (if (characterp ,item) (setf ,item (string ,item))) (if (if ,item (if ,not-preceded-by (if (>= (- ,position (length ,not-preceded-by)) 0) (not (string= (subseq ,string (- ,position (length ,not-preceded-by)) ,position) ,not-preceded-by)) t) t) nil) ,item (progn (and *reset-position* (setf ,position-place *reset-position*)) nil))))) (scan-any (,items &key ,not-preceded-by) (let ((,item (peek-any ,items :not-preceded-by ,not-preceded-by))) (and ,item (advance (length ,item))))) (peek (,item &key ,not-preceded-by) (peek-any (list ,item) :not-preceded-by ,not-preceded-by)) (scan (,item &key ,not-preceded-by) (scan-any (list ,item) :not-preceded-by ,not-preceded-by))) (macrolet ((set-mode (,new-mode &key ,until (,advancing t)) (list 'progn (list 'setf ',mode-place ,new-mode) (list 'setf ',mode-wait-place (list 'lambda (list ',position) (list 'let (list (list '*reset-position* ',position)) (list 'values ,until ,advancing))))))) ,@body)))

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

(with-gensyms (num items position not-preceded-by string item new-mode until advancing) `(labels ((advance (,num) (setf ,position-place (+ ,position-place ,num)) t) (peek-any (,items &key ,not-preceded-by) (incf *scan-calls*) (let* ((,items (if (stringp ,items) (coerce ,items 'list) ,items)) (,not-preceded-by (if (characterp ,not-preceded-by) (string ,not-preceded-by) ,not-preceded-by)) (,position ,position-place) (,string ,string-param)) (let ((,item (and (< ,position (length ,string)) (find ,string ,items :test #'(lambda (,string ,item) #+nil (format t "looking for ~S in ~S starting at ~S~%" ,item ,string ,position) (if (characterp ,item) (char= (elt ,string ,position) ,item) (search ,item ,string :start2 ,position :end2 (min (length ,string) (+ ,position (length ,item)))))))))) (if (characterp ,item) (setf ,item (string ,item))) (if (if ,item (if ,not-preceded-by (if (>= (- ,position (length ,not-preceded-by)) 0) (not (string= (subseq ,string (- ,position (length ,not-preceded-by)) ,position) ,not-preceded-by)) t) t) nil) ,item (progn (and *reset-position* (setf ,position-place *reset-position*)) nil))))) (scan-any (,items &key ,not-preceded-by) (let ((,item (peek-any ,items :not-preceded-by ,not-preceded-by))) (and ,item (advance (length ,item))))) (peek (,item &key ,not-preceded-by) (peek-any (list ,item) :not-preceded-by ,not-preceded-by)) (scan (,item &key ,not-preceded-by) (scan-any (list ,item) :not-preceded-by ,not-preceded-by))) (macrolet ((set-mode (,new-mode &key ,until (,advancing t)) (list 'progn (list 'setf ',mode-place ,new-mode) (list 'setf ',mode-wait-place (list 'lambda (list ',position) (list 'let (list (list '*reset-position* ',position)) (list 'values ,until ,advancing))))))) ,@body)))

[Assistant]
(defmacro with-gensyms ((&rest names) &body body)
  `(let ,(mapcar #'(lambda (name)
                     (list name `(make-symbol ,(symbol-name name)))) names)
    ,@body))

;; macroexpand:
(let ((num (gensym #A((3) base-char . "NUM"))) (items (gensym #A((5) base-char . "ITEMS"))) (position (gensym #A((8) base-char . "POSITION"))) (not-preceded-by (gensym #A((15) base-char . "NOT-PRECEDED-BY"))) (string (gensym #A((6) base-char . "STRING"))) (item (gensym #A((4) base-char . "ITEM"))) (new-mode (gensym #A((8) base-char . "NEW-MODE"))) (until (gensym #A((5) base-char . "UNTIL"))) (advancing (gensym #A((9) base-char . "ADVANCING")))) (sb-int:quasiquote (labels ((advance (#S(sb-impl::comma :expr num :kind 0)) (setf #S(sb-impl::comma :expr position-place :kind 0) (+ #S(sb-impl::comma :expr position-place :kind 0) #S(sb-impl::comma :expr num :kind 0))) t) (peek-any (#S(sb-impl::comma :expr items :kind 0) &key #S(sb-impl::comma :expr not-preceded-by :kind 0)) (incf *scan-calls*) (let* ((#S(sb-impl::comma :expr items :kind 0) (if (stringp #S(sb-impl::comma :expr items :kind 0)) (coerce #S(sb-impl::comma :expr items :kind 0) (quote list)) #S(sb-impl::comma :expr items :kind 0))) (#S(sb-impl::comma :expr not-preceded-by :kind 0) (if (characterp #S(sb-impl::comma :expr not-preceded-by :kind 0)) (string #S(sb-impl::comma :expr not-preceded-by :kind 0)) #S(sb-impl::comma :expr not-preceded-by :kind 0))) (#S(sb-impl::comma :expr position :kind 0) #S(sb-impl::comma :expr position-place :kind 0)) (#S(sb-impl::comma :expr string :kind 0) #S(sb-impl::comma :expr string-param :kind 0))) (let ((#S(sb-impl::comma :expr item :kind 0) (and (< #S(sb-impl::comma :expr position :kind 0) (length #S(sb-impl::comma :expr string :kind 0))) (find #S(sb-impl::comma :expr string :kind 0) #S(sb-impl::comma :expr items :kind 0) :test (function (lambda (#S(sb-impl::comma :expr string :kind 0) #S(sb-impl::comma :expr item :kind 0)) (if (characterp #S(sb-impl::comma :expr item :kind 0)) (char= (elt #S(sb-impl::comma :expr string :kind 0) #S(sb-impl::comma :expr position :kind 0)) #S(sb-impl::comma :expr item :kind 0)) (search #S(sb-impl::comma :expr item :kind 0) #S(sb-impl::comma :expr string :kind 0) :start2 #S(sb-impl::comma :expr position :kind 0) :end2 (min (length #S(sb-impl::comma :expr string :kind 0)) (+ #S(sb-impl::comma :expr position :kind 0) (length #S(sb-impl::comma :expr item :kind 0)))))))))))) (if (characterp #S(sb-impl::comma :expr item :kind 0)) (setf #S(sb-impl::comma :expr item :kind 0) (string #S(sb-impl::comma :expr item :kind 0)))) (if (if #S(sb-impl::comma :expr item :kind 0) (if #S(sb-impl::comma :expr not-preceded-by :kind 0) (if (>= (- #S(sb-impl::comma :expr position :kind 0) (length #S(sb-impl::comma :expr not-preceded-by :kind 0))) 0) (not (string= (subseq #S(sb-impl::comma :expr string :kind 0) (- #S(sb-impl::comma :expr position :kind 0) (length #S(sb-impl::comma :expr not-preceded-by :kind 0))) #S(sb-impl::comma :expr position :kind 0)) #S(sb-impl::comma :expr not-preceded-by :kind 0))) t) t) nil) #S(sb-impl::comma :expr item :kind 0) (progn (and *reset-position* (setf #S(sb-impl::comma :expr position-place :kind 0) *reset-position*)) nil))))) (scan-any (#S(sb-impl::comma :expr items :kind 0) &key #S(sb-impl::comma :expr not-preceded-by :kind 0)) (let ((#S(sb-impl::comma :expr item :kind 0) (peek-any #S(sb-impl::comma :expr items :kind 0) :not-preceded-by #S(sb-impl::comma :expr not-preceded-by :kind 0)))) (and #S(sb-impl::comma :expr item :kind 0) (advance (length #S(sb-impl::comma :expr item :kind 0)))))) (peek (#S(sb-impl::comma :expr item :kind 0) &key #S(sb-impl::comma :expr not-preceded-by :kind 0)) (peek-any (list #S(sb-impl::comma :expr item :kind 0)) :not-preceded-by #S(sb-impl::comma :expr not-preceded-by :kind 0))) (scan (#S(sb-impl::comma :expr item :kind 0) &key #S(sb-impl::comma :expr not-preceded-by :kind 0)) (scan-any (list #S(sb-impl::comma :expr item :kind 0)) :not-preceded-by #S(sb-impl::comma :expr not-preceded-by :kind 0)))) (macrolet ((set-mode (#S(sb-impl::comma :expr new-mode :kind 0) &key #S(sb-impl::comma :expr until :kind 0) (#S(sb-impl::comma :expr advancing :kind 0) t)) (list (quote progn) (list (quote setf) (quote #S(sb-impl::comma :expr mode-place :kind 0)) #S(sb-impl::comma :expr new-mode :kind 0)) (list (quote setf) (quote #S(sb-impl::comma :expr mode-wait-place :kind 0)) (list (quote lambda) (list (quote #S(sb-impl::comma :expr position :kind 0))) (list (quote let) (list (list (quote *reset-position*) (quote #S(sb-impl::comma :expr position :kind 0)))) (list (quote values) #S(sb-impl::comma :expr until :kind 0) #S(sb-impl::comma :expr advancing :kind 0)))))))) #S(sb-impl::comma :expr body :kind 2)))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(ps-to-stream nil)

What needs to change: Macro call that should be transformed by PS-TO-STREAM

(ps-to-stream nil)

[Assistant]
(defmacro PS-TO-STREAM ...)

;; macroexpand:
(let ((*parenscript-stream* nil))
  (write-string "" *parenscript-stream*))


[User]
Generate a defmacro form that transforms code like this:
(compiler-macro-lambda (a) `(1- ,a))

Pattern to recognize: Macro call that should be transformed by compiler-macro-lambda

(compiler-macro-lambda (a) `(1- ,a))

[Assistant]
(defmacro compiler-macro-lambda (lambda-list &body body)
  (introspect-environment:parse-compiler-macro (gensym "COMPILER-MACRO-LAMBDA")
                                               lambda-list
                                               body))

;; macroexpand:
(sb-int:named-lambda (compiler-macro #:compiler-macro-lambda146) (#:expr #:env) (declare (sb-c::lambda-list (a))) (declare (ignore #:env)) (sb-int:named-ds-bind (:macro #:compiler-macro-lambda146 . define-compiler-macro) (a) (sb-c::compiler-macro-args #:expr) (declare (sb-c::constant-value a) (sb-c::no-compiler-macro #:compiler-macro-lambda146)) (block #:compiler-macro-lambda146 (sb-int:quasiquote (1- #S(sb-impl::comma :expr a :kind 0))))))


[User]
Generate a defmacro form that transforms code like this:
(bind (((:labels doit (x)) (declare (type fixnum x)) (setf x (* 2 x)) (setf x (+ x 3)) x)) (ensure-same (doit 1) 5) (ensure-same (doit 2) 7))

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

(bind (((:labels doit (x)) (declare (type fixnum x)) (setf x (* 2 x)) (setf x (+ x 3)) x)) (ensure-same (doit 1) 5) (ensure-same (doit 2) 7))

[Assistant]
(defmacro bind ((&rest bindings) &body body)
  "Bind is a replacement for let*, destructuring-bind, multiple-value-bind and more.

An example is probably the best way to describe its syntax:

    \(bind \(\(a 2\)
           \(\(b &rest args &key \(c 2\) &allow-other-keys\) '\(:a :c 5 :d 10 :e 54\)\)
           \(\(:values d e\) \(truncate 4.5\)\)
           \(\(:structure xxx- slot1 slot2\) \(make-xxx\)\)
           \(\(:flet name \(arg1 arg2\)\) \(+ arg1 arg2\)\)\)
         \(list a b c d e args\)\)

Simple bindings are as in let*. Destructuring is done if the first item
in a binding is a list. Multiple value binding is done if the first item
in a binding is a list and the first item in the list is ':values'. Other
forms have their own syntax. For example, :structure first has the conc
name and then slot names whereas :flet has the function name and a list
of arguments and then the function body (in an implicit progn)."
  (let (declarations)
    (loop while (and (consp (car body)) (eq (caar body) 'declare)) do
          (push (first body) declarations)
          (setf body (rest body)))
    (if bindings
	(let ((*all-declarations* (bind-expand-declarations (nreverse declarations))))
	  (prog1
	      (bind-macro-helper bindings body)
	    (check-for-unused-variable-declarations *all-declarations*)))
        `(locally
             ,@declarations
           ,@body))))

;; macroexpand:
(labels ((doit (x) (declare (type fixnum x)) (progn (setf x (* 2 x)) (setf x (+ x 3)) x))) (progn (ensure-same (doit 1) 5) (ensure-same (doit 2) 7)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defsynonym :thereis :there-is)

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

(defsynonym :thereis :there-is)

[Assistant]
(defmacro defsynonym (symbol synonym)
  "Set SYNONYM for a SYMBOL. "
  `(eval-always
     (setf (get ',symbol 'synonym) ',synonym)))

;; macroexpand:
(eval-always (setf (get (quote :thereis) (quote synonym)) (quote :there-is)))


[User]
Generate a defmacro form that transforms code like this:
(ematch0 tests (nil more-patterns) ((list* test t-rest) `(,intersection (guard1 ,(first syms) ,test ,@(first more-patterns) ,@(wrap-test (rest syms) t-rest (rest more-patterns))))))

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

(ematch0 tests (nil more-patterns) ((list* test t-rest) `(,intersection (guard1 ,(first syms) ,test ,@(first more-patterns) ,@(wrap-test (rest syms) t-rest (rest more-patterns))))))

[Assistant]
(defmacro ematch0 (what &body clauses)
  `(match0 ,what
     ,@clauses
     (_ (error "level0 match error!"))))

;; macroexpand:
(match0 tests (nil more-patterns) ((list* test t-rest) (sb-int:quasiquote (#S(sb-impl::comma :expr intersection :kind 0) (guard1 #S(sb-impl::comma :expr (first syms) :kind 0) #S(sb-impl::comma :expr test :kind 0) #S(sb-impl::comma :expr (first more-patterns) :kind 2) #S(sb-impl::comma :expr (wrap-test (rest syms) t-rest (rest more-patterns)) :kind 2))))) (_ (error "level0 match error!")))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(define-simple-documentation-lookup method-combination cl:method-combination)

What needs to change: Macro call that should be transformed by define-simple-documentation-lookup

(define-simple-documentation-lookup method-combination cl:method-combination)

[Assistant]
(defmacro define-simple-documentation-lookup (class documentation-type)
  `(defmethod documentation ((,class ,class))
     ,(if (eql documentation-type T)
          `(cl:documentation (object ,class) 'T)
          `(cl:documentation (designator ,class) ',documentation-type))))

;; macroexpand:
(defmethod documentation ((method-combination method-combination)) (common-lisp:documentation (designator method-combination) (quote common-lisp:method-combination)))


[User]
Write a Common Lisp macro to handle this code pattern:
(augment body-code (funcall body-during form body))

Problem: Macro call that should be transformed by augment

(augment body-code (funcall body-during form body))

[Assistant]
(defmacro augment (var stuff)
  `(setf ,var (nconc ,var ,stuff)))

;; macroexpand:
(setf body-code (nconc body-code (funcall body-during form body)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defstore example (a b))

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

(defstore example (a b))

[Assistant]
(defmacro defstore (store-name store-lambda-list &body body &environment env)
  (let* ((store-class-name (second (find :store-class body :key #'first)))
         (store-class (etypecase store-class-name
                        (null (find-class 'standard-store))
                        (symbol (find-class store-class-name))))
         (form (apply #'defstore-using-class store-class store-name store-lambda-list
                      :environment env
                      (mapcan #'(lambda (item)
                                  (cond ((eql (first item) :store-class)
                                         `(:store-class ',store-class-name))
                                        ((and (member (first item) '(:documentation :specialization-class)))
                                         (if (= 2 (length item))
                                             item
                                             (error "Invalid store definition option: ~W." item)))
                                        (t
                                         (list (first item) (rest item)))))
                              body))))
    `(eval-when (:compile-toplevel :load-toplevel :execute)
       ,form)))

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (ensure-store (quote example) (quote (a b)))))


[User]
Write a Common Lisp macro to handle this code pattern:
(enable-reader-syntax nil :key nil)

Problem: Macro call that should be transformed by ENABLE-READER-SYNTAX

(enable-reader-syntax nil :key nil)

[Assistant]
(defmacro ENABLE-READER-SYNTAX ...)

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (push *readtable* *previous-readtables*)
  (setq *readtable* (copy-readtable))
  (%enable-reader-syntax *readtable* nil :key nil))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(->> nil (progn))

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

(->> nil (progn))

[Assistant]
(defmacro ->> ...)

;; macroexpand:
(progn nil)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defproto nil :key nil)

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

(defproto nil :key nil)

[Assistant]
(defmacro DEFPROTO ...)

;; macroexpand:
(progn
 (declaim (special nil))
 (eval-when (:compile-toplevel))
 (setf (symbol-value 'nil)
         (ensure-object (when (boundp 'nil) (symbol-value 'nil)) (list :key)
                        :properties (list) :nickname 'nil)))


[User]
Generate a defmacro form that transforms code like this:
(symbol-value-in-$instance nil (progn))

Pattern to recognize: Macro call that should be transformed by SYMBOL-VALUE-IN-$INSTANCE

(symbol-value-in-$instance nil (progn))

[Assistant]
(defmacro SYMBOL-VALUE-IN-$INSTANCE ...)

;; macroexpand:
(slot-value nil (progn))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(match ARG (PATTERN) (otherwise BODY...))

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

(match ARG (PATTERN) (otherwise BODY...))

[Assistant]
(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))

;; macroexpand:
(%or (%or (let ((pattern arg))) body... (fail)) nil)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(specializing nil
    nil)

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

(specializing nil
    nil)

[Assistant]
(defmacro SPECIALIZING ...)

;; macroexpand:
(let ((#:table147 (load-time-value (table 66))))
  (declare (optimize (speed 3) (debug 0) (safety 0)))
  (progn (funcall (the (function nil *) #:table147))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(peek b)

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

(peek b)

[Assistant]
(defmacro peek (form)
  "Read the value of cells without triggering a recomputation.

FORM is evaluated in a context such that when the value of a cell is
referenced it is not registered as an argument cell of the cell in
which the PEEK form is evaluated. This means that the value of the
cell, in which the PEEK form is evaluated, will not be recomputed when
the values of the cells referenced in FORM change.

In the following example

.. code-block::

   (defcell a 0)
   (defcell b 1)

   (defcell sum (+ a (peek b))

the SUM cell references the value of A directly and *peeks* the value
of B (using PEEK). Changing the value of A will cause the value of the
SUM cell to be recomputed. However, changing the value of B will not
cause the value of SUM to be computed.

.. important::

   This macro has no effect if CELL is referenced outside a PEEK form
   within the same cell definition.

   .. code-block::

      (defcell sum (+ b (peek b))

   In this example, PEEK has no effect because the SUM cell references
   B outside a PEEK form.

"

  (with-gensyms (arg-cell
                 did-change
                 observer-arg
                 tracker
                 update
                 will-update)

    (let* ((key ``(peek ,(argument-key ,arg-cell)))
           (observer-record
             `(make-observer
               :key ,key
               :will-update #',will-update
               :update #',update)))

      `(flet ((,update (,arg-cell ,did-change)
                (declare (ignore ,arg-cell ,did-change)))
              (,will-update (,arg-cell)
                (declare (ignore ,arg-cell))))

         (let ((,tracker *track-cell-callback*))
           (with-tracker
               ((,arg-cell)
                 (let ((*track-cell-callback* ,tracker))
                   (track-argument
                    (make-argument
                     :key ,key
                     :add-observer (lambda (,observer-arg)
                                     (declare (ignore ,observer-arg))
                                     (call-add-observer ,arg-cell ,observer-record))
                     :remove-observer (lambda (,observer-arg)
                                        (declare (ignore ,observer-arg))
                                        (call-remove-observer ,arg-cell ,observer-record))))))

             ,form))))))

;; macroexpand:
(flet ((#:update148 (#:arg-cell144 #:did-change145) (declare (ignore #:arg-cell144 #:did-change145))) (#:will-update149 (#:arg-cell144) (declare (ignore #:arg-cell144)))) (let ((#:tracker147 *track-cell-callback*)) (with-tracker ((#:arg-cell144) (let ((*track-cell-callback* #:tracker147)) (track-argument (make-argument :key (sb-int:quasiquote (peek #S(sb-impl::comma :expr (argument-key #:arg-cell144) :kind 0))) :add-observer (lambda (#:observer-arg146) (declare (ignore #:observer-arg146)) (call-add-observer #:arg-cell144 (make-observer :key (sb-int:quasiquote (peek #S(sb-impl::comma :expr (argument-key #:arg-cell144) :kind 0))) :will-update (function #:will-update149) :update (function #:update148)))) :remove-observer (lambda (#:observer-arg146) (declare (ignore #:observer-arg146)) (call-remove-observer #:arg-cell144 (make-observer :key (sb-int:quasiquote (peek #S(sb-impl::comma :expr (argument-key #:arg-cell144) :kind 0))) :will-update (function #:will-update149) :update (function #:update148)))))))) b)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(define FILENAME_MAX 1024)

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

(define FILENAME_MAX 1024)

[Assistant]
(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)))

;; macroexpand:
(progn (eval-when (:compile-toplevel :load-toplevel :execute) (defvar *preprocessor-defines* (make-hash-table)) (setf (gethash (quote filename_max) *preprocessor-defines*) #A((4) base-char . "1024"))) (defparameter filename_max 1024))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defclause options (&rest args &key name atomic-updates) (declare (ignore name atomic-updates)) (make-options :map args))

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

(defclause options (&rest args &key name atomic-updates) (declare (ignore name atomic-updates)) (make-options :map args))

[Assistant]
(defmacro defclause (name arglist &body body)
  "Same as cl:defmacro, but additionally records <name> in *clauses* as a known clause macro."
  `(progn
     (defmacro ,name ,arglist ,@body)
     (pushnew ',name *clauses*)))

;; macroexpand:
(progn (defmacro options (&rest args &key name atomic-updates) (declare (ignore name atomic-updates)) (make-options :map args)) (pushnew (quote options) *clauses*))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(with-capped-stack () (etypecase destination ((eql T) (present thing *standard-output*)) ((eql NIL) (with-output-to-string (stream) (present thing stream))) (stream (present-object thing destination))))

Write a macro that addresses: Macro call that should be transformed by with-capped-stack

(with-capped-stack () (etypecase destination ((eql T) (present thing *standard-output*)) ((eql NIL) (with-output-to-string (stream) (present thing stream))) (stream (present-object thing destination))))

[Assistant]
(defmacro with-capped-stack (() &body body)
  `(stack-capper (lambda () ,@body)))

;; macroexpand:
(stack-capper (lambda nil (etypecase destination ((eql t) (present thing *standard-output*)) ((eql nil) (with-output-to-string (stream) (present thing stream))) (stream (present-object thing destination)))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(define-layered-class nil
  (progn))

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

(define-layered-class nil
  (progn))

[Assistant]
(defmacro DEFINE-LAYERED-CLASS ...)

;; macroexpand:
(defclass nil (progn) nil (:metaclass layered-class) (:in-layer . t))


[User]
Define a macro that eliminates this repetitive pattern:
(gen-lambda-with-sticky-stop () (multiple-value-bind (res signal) (funcall source) (if signal res (sticky-stop))))

Issue: Macro call that should be transformed by gen-lambda-with-sticky-stop

(gen-lambda-with-sticky-stop () (multiple-value-bind (res signal) (funcall source) (if signal res (sticky-stop))))

[Assistant]
(defmacro gen-lambda-with-sticky-stop (&rest rest)
  `(make-instance
    'basic-generator
    :function (sticky-stop-lambda ,@rest)))

;; macroexpand:
(make-instance (quote basic-generator) :function (sticky-stop-lambda nil (multiple-value-bind (res signal) (funcall source) (if signal res (sticky-stop)))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defjs reduce1(k vals) (return (aref vals 0)))

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

(defjs reduce1(k vals) (return (aref vals 0)))

[Assistant]
(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)))))))

;; macroexpand:
(let* ((js-body (parenscript:ps (lambda (k vals) (return (aref vals 0)))))) (setf (gethash (quote reduce1) *js-definitions*) js-body) (defun reduce1 (k vals) (get-element "retval" (car (docs (db.eval js-body k vals))))))


[User]
Define a macro that eliminates this repetitive pattern:
(f0
  'some-name)

Issue: Macro call that should be transformed by F0

(f0
  'some-name)

[Assistant]
(defmacro F0 ...)

;; macroexpand:
(lambda () 'some-name)


[User]
Write a Common Lisp macro to handle this code pattern:
(c? )

Problem: Macro call that should be transformed by c?

(c? )

[Assistant]
(defmacro c? (&body body)
  `(make-c-dependent
    :code ',body
    :value-state :unevaluated
    :rule (c-lambda ,@body)))

;; macroexpand:
(make-c-dependent :code (quote nil) :value-state :unevaluated :rule (c-lambda))


[User]
Generate a defmacro form that transforms code like this:
(with-table-name nil (yield (as-op-right op)))

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

(with-table-name nil (yield (as-op-right op)))

[Assistant]
(defmacro with-table-name (table-name &body body)
  `(let ((*table-name-scope* ,table-name))
     ,@body))

;; macroexpand:
(let ((*table-name-scope* nil)) (yield (as-op-right op)))


[User]
Generate a defmacro form that transforms code like this:
(ψ nil)

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

(ψ nil)

[Assistant]
(defmacro Ψ ...)

;; macroexpand:
(mapcar (λ) nil)


[User]
Define a macro that eliminates this repetitive pattern:
(with-html-string (:p :attrs attrs "bar"))

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

(with-html-string (:p :attrs attrs "bar"))

[Assistant]
(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)))))

;; macroexpand:
(with-output-to-string (*html*) (with-html (:p :attrs attrs "bar")))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(~> (flow:atomically :tag-0 () "Hello") (-> :tag-1 () ", concurrent"))

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

(~> (flow:atomically :tag-0 () "Hello") (-> :tag-1 () ", concurrent"))

[Assistant]
(defmacro ~> (&rest body)
  "See flow:concurrently"
  `(concurrently ,@body))

;; macroexpand:
(concurrently (atomically :tag-0 nil "Hello") (-> :tag-1 nil ", concurrent"))


[User]
Write a Common Lisp macro to handle this code pattern:
(collect-stream nil (progn))

Problem: Macro call that should be transformed by COLLECT-STREAM

(collect-stream nil (progn))

[Assistant]
(defmacro COLLECT-STREAM ...)

;; macroexpand:
(common-lisp:let* ((#:generator-482 (generator (progn))) #:items-477)
  (declare (type generator #:generator-482))
  (tagbody
   #:ll-483
    (setq #:items-477 (next-in #:generator-482 (go end)))
    (common-lisp:funcall #'print #:items-477 nil)
    (go #:ll-483)
   end)
  nil)


[User]
Generate a defmacro form that transforms code like this:
(define nil
  nil)

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

(define nil
  nil)

[Assistant]
(defmacro DEFINE ...)

;; macroexpand:
(eval-when (:load-toplevel :execute)
  (check-if-bound 'nil)
  (setf (get 'nil 'read-macro)
          (lambda (#:stream146)
            (let ((*standard-input* #:stream146))
              nil)))
  'nil)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(action (:after node-application) #'lift-static-dict)

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

(action (:after node-application) #'lift-static-dict)

[Assistant]
(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))))

;; macroexpand:
(make-action (quote :after) (quote node-application) (function lift-static-dict))


[User]
Define a macro that eliminates this repetitive pattern:
(scond ((car x) (setf it :nono)) ((car y) (setf it :yes)))

Issue: Macro call that should be transformed by scond

(scond ((car x) (setf it :nono)) ((car y) (setf it :yes)))

[Assistant]
(defmacro scond (&body clauses)
  "Like COND, except each test-form is bound to IT (via SYMBOL-MACROLET) for the
scope of the corresponsing clause. IT can be set with SETF."
  (labels ((rec (clauses)
	     (if clauses
		 (destructuring-bind ((test &body body) . rest) clauses
		   (if body
		       `(symbolic if ,test (progn ,@body) ,(rec rest))
		       `(symbolic if ,test it ,(rec rest))))
		 nil)))
    (rec clauses)))

;; macroexpand:
(symbolic if (car x) (progn (setf it :nono)) (symbolic if (car y) (progn (setf it :yes)) nil))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(dreletf* 'some-name)

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

(dreletf* 'some-name)

[Assistant]
(defmacro DRELETF* ...)

;; macroexpand:
(dreletf ('nil)
  (dreletf ((some-name nil))
    (progn)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(*> (char #\H) (char #\e))

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

(*> (char #\H) (char #\e))

[Assistant]
(defmacro *> (parser &rest parsers)
  "Combination of parsers yielding the result of the rightmost one."
  (let ((offset (gensym "*>-OFFSET")))
    `(lambda (,offset)
       ,(reduce (lambda (i p)
                  (let ((res  (gensym "*>-RES"))
                        (next (gensym "*>-NEXT")))
                    `(multiple-value-bind (,res ,next) ,i
                       (if (ok? ,res)
                           (funcall ,p ,next)
                           (fail ,next)))))
                parsers
                :initial-value `(funcall ,parser ,offset)))))

;; macroexpand:
(lambda (#:*>-offset206) (multiple-value-bind (#:*>-res207 #:*>-next208) (funcall (char #\LATIN_CAPITAL_LETTER_H) #:*>-offset206) (if (ok? #:*>-res207) (funcall (char #\LATIN_SMALL_LETTER_E) #:*>-next208) (fail #:*>-next208))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(with-took-usec took-usec (fetch-using-connection conn query))

What needs to change: Macro call that should be transformed by with-took-usec

(with-took-usec took-usec (fetch-using-connection conn query))

[Assistant]
(defmacro with-took-usec (var &body body)
  (let ((before (gensym "BEFORE")))
    `(let ((,before (get-internal-real-time)))
       (multiple-value-prog1 (progn ,@body)
         (setf ,var (ceiling
                      (* (- (get-internal-real-time) ,before)
                         #.(/ 1000000 internal-time-units-per-second))))))))

;; macroexpand:
(multiple-value-bind (#:before-unixtime171 #:before-usec172) (sb-ext:get-time-of-day) (multiple-value-prog1 (progn (fetch-using-connection conn query)) (multiple-value-bind (#:after-unixtime173 #:after-usec174) (sb-ext:get-time-of-day) (setf took-usec (+ (* (- #:after-unixtime173 #:before-unixtime171) 1000000) (- #:after-usec174 #:before-usec172))))))


[User]
Generate a defmacro form that transforms code like this:
(signals (error "The form ~S is expected to signal an ~S" '(error "an error") 'error) (error "an error"))

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

(signals (error "The form ~S is expected to signal an ~S" '(error "an error") 'error) (error "an error"))

[Assistant]
(defmacro signals (condition-spec
                   &body body)
  "Generates a pass if BODY signals a condition of type
CONDITION. BODY is evaluated in a block named NIL, CONDITION is
not evaluated."
  (let ((block-name (gensym)))
    (destructuring-bind (condition &optional reason-control &rest reason-args)
        (ensure-list condition-spec)
      `(block ,block-name
         (handler-bind ((,condition (lambda (c)
                                      (declare (ignore c))
                                      ;; ok, body threw condition
                                      (add-result 'test-passed
                                                  :test-expr ',condition)
                                      (return-from ,block-name t))))
           (block nil
             ,@body))
         (process-failure
           ',condition
           ,@(if reason-control
                 `(,reason-control ,@reason-args)
                 `("Failed to signal a ~S" ',condition)))
         (return-from ,block-name nil)))))

;; macroexpand:
(block #:g286 (handler-bind ((error (lambda (c) (declare (ignore c)) (add-result (quote test-passed) :test-expr (quote error)) (return-from #:g286 t)))) (block nil (error "an error"))) (process-failure (quote error) "The form ~S is expected to signal an ~S" (quote (error "an error")) (quote error)) (return-from #:g286 nil))


[User]
Define a macro that eliminates this repetitive pattern:
(letrec-syntax common-lisp:nil)

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

(letrec-syntax common-lisp:nil)

[Assistant]
(defmacro LETREC-SYNTAX ...)

;; macroexpand:
(common-lisp:macrolet common-lisp:nil)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(collect-first 'some-name)

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

(collect-first 'some-name)

[Assistant]
(defmacro COLLECT-FIRST ...)

;; macroexpand:
(common-lisp:let* ((#:generator-640 (generator 'some-name))
                   #:items-634
                   (#:item-636 nil))
  (declare (type generator #:generator-640)
           (type (null-or t) #:item-636))
  (tagbody
   #:ll-641
    (setq #:items-634 (next-in #:generator-640 (go end)))
    (setq #:item-636 #:items-634)
   end)
  #:item-636)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(c-assert (not (member nil old-kids)))

Write a macro that addresses: Macro call that should be transformed by c-assert

(c-assert (not (member nil old-kids)))

[Assistant]
(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)))))

;; macroexpand:
(unless *stop* (unless (not (member nil old-kids)) (c-break "failed assertion: ~a" (quote (not (member nil old-kids))))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defclause to (final-value &key (from 0) by while using) "Variation over from." `(from ,from :to ,final-value :by ,by ,@(when while `(:while ,while)) ,@(when using `(:using ,using))))

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

(defclause to (final-value &key (from 0) by while using) "Variation over from." `(from ,from :to ,final-value :by ,by ,@(when while `(:while ,while)) ,@(when using `(:using ,using))))

[Assistant]
(defmacro defclause (name arglist &body body)
  "Same as cl:defmacro, but additionally records <name> in *clauses* as a known clause macro."
  `(progn
     (defmacro ,name ,arglist ,@body)
     (pushnew ',name *clauses*)))

;; macroexpand:
(progn (defmacro to (final-value &key (from 0) by while using) "Variation over from." (sb-int:quasiquote (from #S(sb-impl::comma :expr from :kind 0) :to #S(sb-impl::comma :expr final-value :kind 0) :by #S(sb-impl::comma :expr by :kind 0) #S(sb-impl::comma :expr (when while (sb-int:quasiquote (:while #S(sb-impl::comma :expr while :kind 0)))) :kind 2) #S(sb-impl::comma :expr (when using (sb-int:quasiquote (:using #S(sb-impl::comma :expr using :kind 0)))) :kind 2)))) (pushnew (quote to) *clauses*))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defparam nil (progn))

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

(defparam nil (progn))

[Assistant]
(defmacro DEFPARAM ...)

;; macroexpand:
(setf (gethash #A((3) base-char . "NIL") cl-rules.core::*parameters*) (progn))


[User]
Generate a defmacro form that transforms code like this:
(is (string= result (dummy-strcat (subseq result 0 split-point) (subseq result split-point))))

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

(is (string= result (dummy-strcat (subseq result 0 split-point) (subseq result split-point))))

[Assistant]
(defmacro is (test &rest reason-args)
  "The DWIM checking operator.

If TEST returns a true value a test-passed result is generated,
otherwise a test-failure result is generated. The reason, unless
REASON-ARGS is provided, is generated based on the form of TEST:

 (predicate expected actual) - Means that we want to check
 whether, according to PREDICATE, the ACTUAL value is
 in fact what we EXPECTED.

 (predicate value) - Means that we want to ensure that VALUE
 satisfies PREDICATE.

 Wrapping the TEST form in a NOT simply produces a negated reason
 string."
  (assert (listp test)
          (test)
          "Argument to IS must be a list, not ~S" test)
  (let (bindings effective-test default-reason-args)
    (with-gensyms (e a v)
      (flet ((process-entry (predicate expected actual &optional negatedp)
               ;; make sure EXPECTED is holding the entry that starts with 'values
               (when (and (consp actual)
                          (eq (car actual) 'values))
                 (assert (not (and (consp expected)
                                   (eq (car expected) 'values))) ()
                                   "Both the expected and actual part is a values expression.")
                 (rotatef expected actual))
               (let ((setf-forms))
                 (if (and (consp expected)
                          (eq (car expected) 'values))
                     (progn
                       (setf expected (copy-list expected))
                       (setf setf-forms (loop for cell = (rest expected) then (cdr cell)
                                              for i from 0
                                              while cell
                                              when (eq (car cell) '*)
                                              collect `(setf (elt ,a ,i) nil)
                                              and do (setf (car cell) nil)))
                       (setf bindings (list (list e `(list ,@(rest expected)))
                                            (list a `(multiple-value-list ,actual)))))
                     (setf bindings (list (list e expected)
                                          (list a actual))))
                 (setf effective-test `(progn
                                         ,@setf-forms
                                         ,(if negatedp
                                              `(not (,predicate ,e ,a))
                                              `(,predicate ,e ,a)))))))
        (list-match-case test
          ((not (?predicate ?expected ?actual))
           (process-entry ?predicate ?expected ?actual t)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is ~2&~S~2%to ~2&~S~2% (it should not be)"
                       `',?actual a `',?predicate e)))
          ((not (?satisfies ?value))
           (setf bindings (list (list v ?value))
                 effective-test `(not (,?satisfies ,v))
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which satisfies ~2&~S~2% (it should not)"
                       `',?value v `',?satisfies)))
          ((?predicate ?expected ?actual)
           (process-entry ?predicate ?expected ?actual)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%"
                       `',?actual a `',?predicate e)))
          ((?satisfies ?value)
           (setf bindings (list (list v ?value))
                 effective-test `(,?satisfies ,v)
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which does not satisfy ~2&~S~2%"
                       `',?value v `',?satisfies)))
          (?_
           (setf bindings '()
                 effective-test test
                 default-reason-args (list "~2&~S~2% was NIL." `',test)))))
      `(let ,bindings
         (if ,effective-test
             (add-result 'test-passed :test-expr ',test)
             (process-failure ',test
                              ,@(or reason-args default-reason-args)))))))

;; macroexpand:
(let ((#:e167 result) (#:a168 (dummy-strcat (subseq result 0 split-point) (subseq result split-point)))) (if (progn (string= #:e167 #:a168)) (add-result (quote test-passed) :test-expr (quote (string= result (dummy-strcat (subseq result 0 split-point) (subseq result split-point))))) (process-failure (quote (string= result (dummy-strcat (subseq result 0 split-point) (subseq result split-point)))) "~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%" (quote (dummy-strcat (subseq result 0 split-point) (subseq result split-point))) #:a168 (quote string=) #:e167)))


[User]
Generate a defmacro form that transforms code like this:
(defcell b 1)

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

(defcell b 1)

[Assistant]
(defmacro defcell (name value-form &environment env)
  "Define a global cell identified by NAME.

This macro defines a cell identified by NAME with its value computed
by VALUE-FORM. The value of the cell can be referenced by the symbol
NAME following the DEFCELL form.

If VALUE-FORM is a constant, by CONSTANTP, a mutable cell is defined
which can have its value set directly using SETF or SETQ on the symbol
NAME.

If VALUE-FORM is not a constant a computed cell is created. A computed
cell may reference one or more argument cells in VALUE-FORM or a
function called during the evaluation of VALUE-FORM.  When the values
of any of the argument cells change, the value of the computed cell is
recomputed by evaluating VALUE-FORM again. The referenced argument
cells are determined automatically when the VALUE-FORM is evaluated.

This macro creates a cell definition that is visible globally to all
forms unless it is lexically shadowed by a definition with the same
NAME using CELL-LET. Note that despite being visible globally, the
cell definition is still lexically scoped and not dynamically scoped
like global variables defined with DEFVAR or DEFPARAMETER."

  (if (constantp value-form env)
      `(define-mutable-cell% ,name ,value-form)
      `(define-computed-cell% ,name ,value-form)))

;; macroexpand:
(define-mutable-cell% b 1)


[User]
Generate a defmacro form that transforms code like this:
(define-alias-binding maximize maximizing)

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

(define-alias-binding maximize maximizing)

[Assistant]
(defmacro define-alias-binding (name referenced-binding-name)
  `(progn (setf (binding ',name) ',referenced-binding-name)
          ',name))

;; macroexpand:
(progn (setf (binding (quote maximize)) (quote maximizing)) (quote maximize))


[User]
Define a macro that eliminates this repetitive pattern:
(is (integerp a))

Issue: Macro call that should be transformed by is

(is (integerp a))

[Assistant]
(defmacro is (test &rest reason-args)
  "The DWIM checking operator.

If TEST returns a true value a test-passed result is generated,
otherwise a test-failure result is generated. The reason, unless
REASON-ARGS is provided, is generated based on the form of TEST:

 (predicate expected actual) - Means that we want to check
 whether, according to PREDICATE, the ACTUAL value is
 in fact what we EXPECTED.

 (predicate value) - Means that we want to ensure that VALUE
 satisfies PREDICATE.

 Wrapping the TEST form in a NOT simply produces a negated reason
 string."
  (assert (listp test)
          (test)
          "Argument to IS must be a list, not ~S" test)
  (let (bindings effective-test default-reason-args)
    (with-gensyms (e a v)
      (flet ((process-entry (predicate expected actual &optional negatedp)
               ;; make sure EXPECTED is holding the entry that starts with 'values
               (when (and (consp actual)
                          (eq (car actual) 'values))
                 (assert (not (and (consp expected)
                                   (eq (car expected) 'values))) ()
                                   "Both the expected and actual part is a values expression.")
                 (rotatef expected actual))
               (let ((setf-forms))
                 (if (and (consp expected)
                          (eq (car expected) 'values))
                     (progn
                       (setf expected (copy-list expected))
                       (setf setf-forms (loop for cell = (rest expected) then (cdr cell)
                                              for i from 0
                                              while cell
                                              when (eq (car cell) '*)
                                              collect `(setf (elt ,a ,i) nil)
                                              and do (setf (car cell) nil)))
                       (setf bindings (list (list e `(list ,@(rest expected)))
                                            (list a `(multiple-value-list ,actual)))))
                     (setf bindings (list (list e expected)
                                          (list a actual))))
                 (setf effective-test `(progn
                                         ,@setf-forms
                                         ,(if negatedp
                                              `(not (,predicate ,e ,a))
                                              `(,predicate ,e ,a)))))))
        (list-match-case test
          ((not (?predicate ?expected ?actual))
           (process-entry ?predicate ?expected ?actual t)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is ~2&~S~2%to ~2&~S~2% (it should not be)"
                       `',?actual a `',?predicate e)))
          ((not (?satisfies ?value))
           (setf bindings (list (list v ?value))
                 effective-test `(not (,?satisfies ,v))
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which satisfies ~2&~S~2% (it should not)"
                       `',?value v `',?satisfies)))
          ((?predicate ?expected ?actual)
           (process-entry ?predicate ?expected ?actual)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%"
                       `',?actual a `',?predicate e)))
          ((?satisfies ?value)
           (setf bindings (list (list v ?value))
                 effective-test `(,?satisfies ,v)
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which does not satisfy ~2&~S~2%"
                       `',?value v `',?satisfies)))
          (?_
           (setf bindings '()
                 effective-test test
                 default-reason-args (list "~2&~S~2% was NIL." `',test)))))
      `(let ,bindings
         (if ,effective-test
             (add-result 'test-passed :test-expr ',test)
             (process-failure ',test
                              ,@(or reason-args default-reason-args)))))))

;; macroexpand:
(let ((#:v124 a)) (if (integerp #:v124) (add-result (quote test-passed) :test-expr (quote (integerp a))) (process-failure (quote (integerp a)) "~2&~S~2% evaluated to ~2&~S~2% which does not satisfy ~2&~S~2%" (quote a) #:v124 (quote integerp))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defclause collecting-into-and-returning (vars &rest args &key initially by finally) "Same as collecting-into, but also returns the value of each <vars> at the end of the loop." (declare (ignore initially by finally)) `((collecting-into ,vars ,@args) ,@(mapcar (lambda (var) `(returning ,var)) (ensure-list vars))))

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

(defclause collecting-into-and-returning (vars &rest args &key initially by finally) "Same as collecting-into, but also returns the value of each <vars> at the end of the loop." (declare (ignore initially by finally)) `((collecting-into ,vars ,@args) ,@(mapcar (lambda (var) `(returning ,var)) (ensure-list vars))))

[Assistant]
(defmacro defclause (name arglist &body body)
  "Same as cl:defmacro, but additionally records <name> in *clauses* as a known clause macro."
  `(progn
     (defmacro ,name ,arglist ,@body)
     (pushnew ',name *clauses*)))

;; macroexpand:
(progn (defmacro collecting-into-and-returning (vars &rest args &key initially by finally) "Same as collecting-into, but also returns the value of each <vars> at the end of the loop." (declare (ignore initially by finally)) (sb-int:quasiquote ((collecting-into #S(sb-impl::comma :expr vars :kind 0) #S(sb-impl::comma :expr args :kind 2)) #S(sb-impl::comma :expr (mapcar (lambda (var) (sb-int:quasiquote (returning #S(sb-impl::comma :expr var :kind 0)))) (ensure-list vars)) :kind 2)))) (pushnew (quote collecting-into-and-returning) *clauses*))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(c-assert (not (find c *call-stack*)))

Write a macro that addresses: Macro call that should be transformed by c-assert

(c-assert (not (find c *call-stack*)))

[Assistant]
(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)))))

;; macroexpand:
(unless *stop* (unless (not (find c *call-stack*)) (c-break "failed assertion: ~a" (quote (not (find c *call-stack*))))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(with-mocks () (register-mock 'foo) (register-mock 'bar) (bt:make-thread (lambda () (foo) (bar))) (is (assert-cond (lambda () (and (equal '((foo)) (invocations 'foo)) (equal '((bar)) (invocations 'bar)))) .5)))

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

(with-mocks () (register-mock 'foo) (register-mock 'bar) (bt:make-thread (lambda () (foo) (bar))) (is (assert-cond (lambda () (and (equal '((foo)) (invocations 'foo)) (equal '((bar)) (invocations 'bar)))) .5)))

[Assistant]
(defmacro with-mocks ((&key (recordp T)) &body body)
  "Execute BODY in a new mocking context.  Invocations will be recorded
if RECORDP is set (default true)."
  `(call-with-mocks
    (lambda () ,@body)
    :recordp ,recordp))

;; macroexpand:
(call-with-mocks (lambda nil (register-mock (quote foo)) (register-mock (quote bar)) (bordeaux-threads:make-thread (lambda nil (foo) (bar))) (is (assert-cond (lambda nil (and (equal (quote ((foo))) (invocations (quote foo))) (equal (quote ((bar))) (invocations (quote bar))))) 0.5))) :recordp t)


[User]
Generate a defmacro form that transforms code like this:
(define-mustache-character #\= (let ((arg-text (string-trim '(#\Space #\Tab #\=) arg-text))) (prog1 (make-instance 'delimiter-tag :text arg-text) (change-delimiter arg-text))))

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

(define-mustache-character #\= (let ((arg-text (string-trim '(#\Space #\Tab #\=) arg-text))) (prog1 (make-instance 'delimiter-tag :text arg-text) (change-delimiter arg-text))))

[Assistant]
(defmacro define (name template)
  "Define a named renderer of string TEMPLATE."
  `(setf (symbol-function ',name)
         (compile-template ,template)))

;; macroexpand:
(set-mustache-character #\EQUALS_SIGN (lambda (raw-text arg-text escapep start end) (declare (ignorable raw-text arg-text escapep start end) (type simple-string raw-text arg-text) (boolean escapep) (offset start end)) (let ((arg-text (string-trim (quote (#\Space #\Tab #\EQUALS_SIGN)) arg-text))) (prog1 (make-instance (quote delimiter-tag) :text arg-text) (change-delimiter arg-text)))))


[User]
Write a Common Lisp macro to handle this code pattern:
(signal-syntax-error "Register 0 doesn't exist: ~S." parse-tree)

Problem: Macro call that should be transformed by signal-syntax-error

(signal-syntax-error "Register 0 doesn't exist: ~S." parse-tree)

[Assistant]
(defmacro signal-syntax-error (format-control &rest format-arguments)
  `(signal-syntax-error* nil ,format-control ,@format-arguments))

;; macroexpand:
(signal-syntax-error* nil "Register 0 doesn't exist: ~S." parse-tree)


[User]
Generate a defmacro form that transforms code like this:
(define-simple-definition-resolver package find-package)

Pattern to recognize: Macro call that should be transformed by define-simple-definition-resolver

(define-simple-definition-resolver package find-package)

[Assistant]
(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))))))

;; macroexpand:
(define-definition-resolver package (package #:package132) (when (ignore-errors (find-package package)) (list (make-instance (quote package) :designator package :package #:package132))))


[User]
Define a macro that eliminates this repetitive pattern:
(define-global-parameter* nil (progn))

Issue: Macro call that should be transformed by DEFINE-GLOBAL-PARAMETER*

(define-global-parameter* nil (progn))

[Assistant]
(defmacro DEFINE-GLOBAL-PARAMETER* ...)

;; macroexpand:
(progn
 (setf (get 'nil +value-key+) (progn))
 (sb-ext:define-load-time-global nil (get 'nil +value-key+))
 (setf nil (get 'nil +value-key+))
 (remprop 'nil +value-key+)
 'nil)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(lambda-match
  nil)

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

(lambda-match
  nil)

[Assistant]
(defmacro LAMBDA-MATCH ...)

;; macroexpand:
(lambda (#:arg146)
  (match #:arg146
    nil))


[User]
Generate a defmacro form that transforms code like this:
(compiler-macro-lambda (a) `(1+ ,a))

Pattern to recognize: Macro call that should be transformed by compiler-macro-lambda

(compiler-macro-lambda (a) `(1+ ,a))

[Assistant]
(defmacro compiler-macro-lambda (lambda-list &body body)
  (introspect-environment:parse-compiler-macro (gensym "COMPILER-MACRO-LAMBDA")
                                               lambda-list
                                               body))

;; macroexpand:
(sb-int:named-lambda (compiler-macro #:compiler-macro-lambda148) (#:expr #:env) (declare (sb-c::lambda-list (a))) (declare (ignore #:env)) (sb-int:named-ds-bind (:macro #:compiler-macro-lambda148 . define-compiler-macro) (a) (sb-c::compiler-macro-args #:expr) (declare (sb-c::constant-value a) (sb-c::no-compiler-macro #:compiler-macro-lambda148)) (block #:compiler-macro-lambda148 (sb-int:quasiquote (1+ #S(sb-impl::comma :expr a :kind 0))))))


[User]
Define a macro that eliminates this repetitive pattern:
(defjsmacro)

Issue: Macro call that should be transformed by DEFJSMACRO

(defjsmacro)

[Assistant]
(defmacro DEFJSMACRO ...)

;; macroexpand:
(defpsmacro)


[User]
Write a Common Lisp macro to handle this code pattern:
(with-sql-logging (mapc #'execute-sql (migration-expressions class)))

Problem: Macro call that should be transformed by with-sql-logging

(with-sql-logging (mapc #'execute-sql (migration-expressions class)))

[Assistant]
(defmacro with-sql-logging (&body body)
  `(let ((*mito-logger-stream* *mito-migration-logger-stream*))
     (with-trace-sql ,@body)))

;; macroexpand:
(let ((*mito-logger-stream* *mito-migration-logger-stream*)) (with-trace-sql (mapc (function execute-sql) (migration-expressions class))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(with-wcs-math-error-handling (ret (log x (float 10 x))) (check-wcs-math-result))

What needs to change: Macro call that should be transformed by with-wcs-math-error-handling

(with-wcs-math-error-handling (ret (log x (float 10 x))) (check-wcs-math-result))

[Assistant]
(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))))))

;; macroexpand:
(let* ((#:g224 x) (#:g225 (float 10 x)) (#:g226 (list #:g224 #:g225))) (declare (ignorable #:g225) (type list #:g226) (dynamic-extent #:g226)) (catch (quote return-from-with-wcs-math-error-handling) (multiple-value-bind (ret) (call-with-wcs-math-error-handler (quote log) #:g226) (flet ((check-wcs-math-result (&optional (ret ret) (arg-list #:g226)) (check-wcs-math-result ret arg-list))) (check-wcs-math-result)))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(letmatch nil
    nil)

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

(letmatch nil
    nil)

[Assistant]
(defmacro LETMATCH ...)

;; macroexpand:
(ifmatch (nil nil nil (error "LETMATCH:  mismatch.")))


[User]
Define a macro that eliminates this repetitive pattern:
(some->> nil nil)

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

(some->> nil nil)

[Assistant]
(defmacro SOME->> ...)

;; macroexpand:
(let* ((#:g126 nil))
  (if (null #:g126)
      nil
      (->> #:g126 nil)))


[User]
Define a macro that eliminates this repetitive pattern:
(lexpr-$send nil :key nil)

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

(lexpr-$send nil :key nil)

[Assistant]
(defmacro LEXPR-$SEND ...)

;; macroexpand:
(apply #'send-message nil :key nil)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(destructuring-match nil
  (progn))

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

(destructuring-match nil
  (progn))

[Assistant]
(defmacro DESTRUCTURING-MATCH ...)

;; macroexpand:
(let ((#:form nil))
  (block #:done
    (let ((#:done
           (lambda (&rest values)
             (declare (dynamic-extent values))
             (return-from #:done (values-list values)))))
      (tagbody
        (funcall
         (lambda (#:thing #:fail)
           (let ((progn #:thing) (#:thing 'nil))
             (if (not (null #:thing))
                 (org.tfeb.dsm/impl::fail #:fail "extra arguments")
                 (locally (multiple-value-call #:done (progn))))))
         #:form
         (lambda (message arguments)
           (declare (ignore message arguments))
           (go #:next)))
       #:next))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(alter nil (progn))

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

(alter nil (progn))

[Assistant]
(defmacro ALTER ...)

;; macroexpand:
(compiler-let ((*optimize-series-expressions* nil)) (alter nil (progn)))


[User]
Define a macro that eliminates this repetitive pattern:
(deferror "42501" insufficient-privilege syntax-error-or-access-violation)

Issue: Macro call that should be transformed by deferror

(deferror "42501" insufficient-privilege syntax-error-or-access-violation)

[Assistant]
(defmacro deferror (code typename &optional (superclass 'database-error))
  `(progn (define-condition ,typename (,superclass) ())
          (setf (gethash ,code *error-table*) ',typename)))

;; macroexpand:
(progn (define-condition insufficient-privilege (syntax-error-or-access-violation) nil) (setf (gethash "42501" *error-table*) (quote insufficient-privilege)))


[User]
Generate a defmacro form that transforms code like this:
(as-> nil :key nil)

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

(as-> nil :key nil)

[Assistant]
(defmacro AS-> ...)

;; macroexpand:
(let* ((:key nil) (:key nil))
  :key)


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

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

(with-decoder-simple-list-semantics (let ((*json-symbols-package* 'json-test)) (decode-json-from-string encoded)))

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

;; macroexpand:
(with-shadowed-custom-vars (set-decoder-simple-list-semantics) (let ((*json-symbols-package* (quote json-test))) (decode-json-from-string encoded)))


[User]
Generate a defmacro form that transforms code like this:
(defun/1 fputs (str fd) (handler-case (progn (write-string (char*-to-string str) (fd-stream fd)) 0) (error () (setf (ferror fd) EIO) EOF)))

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

(defun/1 fputs (str fd) (handler-case (progn (write-string (char*-to-string str) (fd-stream fd)) 0) (error () (setf (ferror fd) EIO) EOF)))

[Assistant]
(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)))))

;; macroexpand:
(progn (defun fputs (str fd) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (handler-case (progn (write-string (char*-to-string str) (fd-stream fd)) 0) (error nil (setf (ferror fd) eio) eof))) (defparameter fputs (vacietis.c:mkptr& (symbol-function (quote fputs)))))


[User]
Define a macro that eliminates this repetitive pattern:
(defun-compile-time indirect-callers-internal (function-names callers) (if (null function-names) callers (let ((function-name (first function-names))) (if (member function-name callers :test #'equal) (indirect-callers-internal (rest function-names) callers) (indirect-callers-internal (rest function-names) (indirect-callers-internal (callers function-name) (cons function-name callers)))))))

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

(defun-compile-time indirect-callers-internal (function-names callers) (if (null function-names) callers (let ((function-name (first function-names))) (if (member function-name callers :test #'equal) (indirect-callers-internal (rest function-names) callers) (indirect-callers-internal (rest function-names) (indirect-callers-internal (callers function-name) (cons function-name callers)))))))

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

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:defun indirect-callers-internal (function-names callers) (if (null function-names) callers (let ((function-name (first function-names))) (if (member function-name callers :test (function equal)) (indirect-callers-internal (rest function-names) callers) (indirect-callers-internal (rest function-names) (indirect-callers-internal (callers function-name) (cons function-name callers))))))) (eval-when (:compile-toplevel) (compile (quote indirect-callers-internal))))


[User]
Define a macro that eliminates this repetitive pattern:
(bind (((:structure metabang-bind-test-1- (my-a a) c) c1) ((:structure metabang-bind-test-1- a b (second-c c)) c2)) (list my-a c a b second-c))

Issue: Macro call that should be transformed by bind

(bind (((:structure metabang-bind-test-1- (my-a a) c) c1) ((:structure metabang-bind-test-1- a b (second-c c)) c2)) (list my-a c a b second-c))

[Assistant]
(defmacro bind ((&rest bindings) &body body)
  "Bind is a replacement for let*, destructuring-bind, multiple-value-bind and more.

An example is probably the best way to describe its syntax:

    \(bind \(\(a 2\)
           \(\(b &rest args &key \(c 2\) &allow-other-keys\) '\(:a :c 5 :d 10 :e 54\)\)
           \(\(:values d e\) \(truncate 4.5\)\)
           \(\(:structure xxx- slot1 slot2\) \(make-xxx\)\)
           \(\(:flet name \(arg1 arg2\)\) \(+ arg1 arg2\)\)\)
         \(list a b c d e args\)\)

Simple bindings are as in let*. Destructuring is done if the first item
in a binding is a list. Multiple value binding is done if the first item
in a binding is a list and the first item in the list is ':values'. Other
forms have their own syntax. For example, :structure first has the conc
name and then slot names whereas :flet has the function name and a list
of arguments and then the function body (in an implicit progn)."
  (let (declarations)
    (loop while (and (consp (car body)) (eq (caar body) 'declare)) do
          (push (first body) declarations)
          (setf body (rest body)))
    (if bindings
	(let ((*all-declarations* (bind-expand-declarations (nreverse declarations))))
	  (prog1
	      (bind-macro-helper bindings body)
	    (check-for-unused-variable-declarations *all-declarations*)))
        `(locally
             ,@declarations
           ,@body))))

;; macroexpand:
(let* ((#:|values-193| c1) (my-a (metabang-bind-test-1-a #:|values-193|)) (c (metabang-bind-test-1-c #:|values-193|)) (#:|values-192| c2) (a (metabang-bind-test-1-a #:|values-192|)) (b (metabang-bind-test-1-b #:|values-192|)) (second-c (metabang-bind-test-1-c #:|values-192|))) (declare (ignorable #:|values-193|)) (declare (ignorable #:|values-192|)) (progn (list my-a c a b second-c)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(with-flow-function-macro (body-fu lambda-list fu-body) `(dispatch-asynchronously ,flow-context #',body-fu))

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

(with-flow-function-macro (body-fu lambda-list fu-body) `(dispatch-asynchronously ,flow-context #',body-fu))

[Assistant]
(defmacro with-flow-function-macro ((fu-name fu-lambda-list fu-body) &body body)
  `(with-gensyms (,fu-name)
     `(%with-flow-function (,,fu-name ,,fu-lambda-list ,@,fu-body)
        ,,@body)))

;; macroexpand:
(with-gensyms (body-fu) (sb-int:quasiquote (%with-flow-function (#S(sb-impl::comma :expr body-fu :kind 0) #S(sb-impl::comma :expr lambda-list :kind 0) #S(sb-impl::comma :expr fu-body :kind 2)) #S(sb-impl::comma :expr (sb-int:quasiquote (dispatch-asynchronously #S(sb-impl::comma :expr flow-context :kind 0) (function #S(sb-impl::comma :expr body-fu :kind 0)))) :kind 0))))


[User]
Define a macro that eliminates this repetitive pattern:
(define-component parenscript :input-type "lisp" :output-type "js" :compile-function (lambda (input-pathname output-pathname) (with-open-file (stream output-pathname :direction :output :if-exists :supersede :if-does-not-exist :create) (write-string (parenscript:ps-compile-file input-pathname) stream))))

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

(define-component parenscript :input-type "lisp" :output-type "js" :compile-function (lambda (input-pathname output-pathname) (with-open-file (stream output-pathname :direction :output :if-exists :supersede :if-does-not-exist :create) (write-string (parenscript:ps-compile-file input-pathname) stream))))

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

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

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

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

     (import ',name :asdf)))

;; macroexpand:
(progn (defclass parenscript (source-file) ((type :initform "lisp") (output :reader output :initarg :output))) (defmethod perform ((o load-op) (component parenscript)) t) (defmethod output-files ((operation compile-op) (component parenscript)) (list (output-pathname component "js"))) (defmethod perform ((o compile-op) (component parenscript)) (funcall (lambda (input-pathname output-pathname) (with-open-file (stream output-pathname :direction :output :if-exists :supersede :if-does-not-exist :create) (write-string (parenscript:ps-compile-file input-pathname) stream))) (component-pathname component) (output-pathname component "js"))) (import (quote parenscript) :asdf))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(untrace$method 'some-name)

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

(untrace$method 'some-name)

[Assistant]
(defmacro UNTRACE$METHOD ...)

;; macroexpand:
(mcs-untrace quote some-name)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(signal-syntax-error* start-pos "Missing right bracket to close character class.")

Write a macro that addresses: Macro call that should be transformed by signal-syntax-error*

(signal-syntax-error* start-pos "Missing right bracket to close character class.")

[Assistant]
(defmacro signal-syntax-error* (pos format-control &rest format-arguments)
  `(error 'ppcre-syntax-error
          :pos ,pos
          :format-control ,format-control
          :format-arguments (list ,@format-arguments)))

;; macroexpand:
(error (quote ppcre-syntax-error) :pos start-pos :format-control "Missing right bracket to close character class." :format-arguments (list))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(with-xml-group-element (s "tspan" opts) (string->xml s text))

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

(with-xml-group-element (s "tspan" opts) (string->xml s text))

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

;; macroexpand:
(let ((#:|stream134| s) (#:|element135| "tspan")) (begin-group->xml #:|stream134| #:|element135| opts) (with-indentation (string->xml s text)) (end-group->xml #:|stream134| #:|element135|))


[User]
Generate a defmacro form that transforms code like this:
(define-mustache-character #\! (make-instance 'comment-tag :text ""))

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

(define-mustache-character #\! (make-instance 'comment-tag :text ""))

[Assistant]
(defmacro define (name template)
  "Define a named renderer of string TEMPLATE."
  `(setf (symbol-function ',name)
         (compile-template ,template)))

;; macroexpand:
(set-mustache-character #\EXCLAMATION_MARK (lambda (raw-text arg-text escapep start end) (declare (ignorable raw-text arg-text escapep start end) (type simple-string raw-text arg-text) (boolean escapep) (offset start end)) (make-instance (quote comment-tag) :text "")))


[User]
Define a macro that eliminates this repetitive pattern:
(*> +consume-ws+ +any-crlf+)

Issue: Macro call that should be transformed by *>

(*> +consume-ws+ +any-crlf+)

[Assistant]
(defmacro *> (parser &rest parsers)
  "Combination of parsers yielding the result of the rightmost one."
  (let ((offset (gensym "*>-OFFSET")))
    `(lambda (,offset)
       ,(reduce (lambda (i p)
                  (let ((res  (gensym "*>-RES"))
                        (next (gensym "*>-NEXT")))
                    `(multiple-value-bind (,res ,next) ,i
                       (if (ok? ,res)
                           (funcall ,p ,next)
                           (fail ,next)))))
                parsers
                :initial-value `(funcall ,parser ,offset)))))

;; macroexpand:
(lambda (#:*>-offset128) (multiple-value-bind (#:*>-res129 #:*>-next130) (funcall +consume-ws+ #:*>-offset128) (if (ok? #:*>-res129) (funcall +any-crlf+ #:*>-next130) (fail #:*>-next130))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(with-symbol-access
  nil
  (progn))

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

(with-symbol-access
  nil
  (progn))

[Assistant]
(defmacro WITH-SYMBOL-ACCESS ...)

;; macroexpand:
(let ((*symbol-access* t))
  nil
  (progn))


[User]
Generate a defmacro form that transforms code like this:
(enable-quasi-quoted-bivalent-to-binary-emitting-form-syntax 'some-name)

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

(enable-quasi-quoted-bivalent-to-binary-emitting-form-syntax 'some-name)

[Assistant]
(defmacro ENABLE-QUASI-QUOTED-BIVALENT-TO-BINARY-EMITTING-FORM-SYNTAX ...)

;; macroexpand:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-quasi-quoted-bivalent-to-binary-emitting-form-syntax-in-readtable
   'some-name :with-inline-emitting nil :declarations 'nil :start-character nil
   :end-character nil :unquote-character #\COMMA :splice-character
   #\COMMERCIAL_AT :destructive-splice-character #\FULL_STOP
   :dispatched-quasi-quote-name "biv" :encoding *default-character-encoding*)
  (values))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(is (= 0 (add-4 -4)))

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

(is (= 0 (add-4 -4)))

[Assistant]
(defmacro is (test &rest reason-args)
  "The DWIM checking operator.

If TEST returns a true value a test-passed result is generated,
otherwise a test-failure result is generated. The reason, unless
REASON-ARGS is provided, is generated based on the form of TEST:

 (predicate expected actual) - Means that we want to check
 whether, according to PREDICATE, the ACTUAL value is
 in fact what we EXPECTED.

 (predicate value) - Means that we want to ensure that VALUE
 satisfies PREDICATE.

 Wrapping the TEST form in a NOT simply produces a negated reason
 string."
  (assert (listp test)
          (test)
          "Argument to IS must be a list, not ~S" test)
  (let (bindings effective-test default-reason-args)
    (with-gensyms (e a v)
      (flet ((process-entry (predicate expected actual &optional negatedp)
               ;; make sure EXPECTED is holding the entry that starts with 'values
               (when (and (consp actual)
                          (eq (car actual) 'values))
                 (assert (not (and (consp expected)
                                   (eq (car expected) 'values))) ()
                                   "Both the expected and actual part is a values expression.")
                 (rotatef expected actual))
               (let ((setf-forms))
                 (if (and (consp expected)
                          (eq (car expected) 'values))
                     (progn
                       (setf expected (copy-list expected))
                       (setf setf-forms (loop for cell = (rest expected) then (cdr cell)
                                              for i from 0
                                              while cell
                                              when (eq (car cell) '*)
                                              collect `(setf (elt ,a ,i) nil)
                                              and do (setf (car cell) nil)))
                       (setf bindings (list (list e `(list ,@(rest expected)))
                                            (list a `(multiple-value-list ,actual)))))
                     (setf bindings (list (list e expected)
                                          (list a actual))))
                 (setf effective-test `(progn
                                         ,@setf-forms
                                         ,(if negatedp
                                              `(not (,predicate ,e ,a))
                                              `(,predicate ,e ,a)))))))
        (list-match-case test
          ((not (?predicate ?expected ?actual))
           (process-entry ?predicate ?expected ?actual t)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is ~2&~S~2%to ~2&~S~2% (it should not be)"
                       `',?actual a `',?predicate e)))
          ((not (?satisfies ?value))
           (setf bindings (list (list v ?value))
                 effective-test `(not (,?satisfies ,v))
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which satisfies ~2&~S~2% (it should not)"
                       `',?value v `',?satisfies)))
          ((?predicate ?expected ?actual)
           (process-entry ?predicate ?expected ?actual)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%"
                       `',?actual a `',?predicate e)))
          ((?satisfies ?value)
           (setf bindings (list (list v ?value))
                 effective-test `(,?satisfies ,v)
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which does not satisfy ~2&~S~2%"
                       `',?value v `',?satisfies)))
          (?_
           (setf bindings '()
                 effective-test test
                 default-reason-args (list "~2&~S~2% was NIL." `',test)))))
      `(let ,bindings
         (if ,effective-test
             (add-result 'test-passed :test-expr ',test)
             (process-failure ',test
                              ,@(or reason-args default-reason-args)))))))

;; macroexpand:
(let ((#:e143 0) (#:a144 (add-4 -4))) (if (progn (= #:e143 #:a144)) (add-result (quote test-passed) :test-expr (quote (= 0 (add-4 -4)))) (process-failure (quote (= 0 (add-4 -4))) "~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%" (quote (add-4 -4)) #:a144 (quote =) #:e143)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(ƒƒ nil)

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

(ƒƒ nil)

[Assistant]
(defmacro ƑƑ ...)

;; macroexpand:
(defun nil (&optional α) (cond))


[User]
Write a Common Lisp macro to handle this code pattern:
(*> +consume-space+ +close-bracket+)

Problem: Macro call that should be transformed by *>

(*> +consume-space+ +close-bracket+)

[Assistant]
(defmacro *> (parser &rest parsers)
  "Combination of parsers yielding the result of the rightmost one."
  (let ((offset (gensym "*>-OFFSET")))
    `(lambda (,offset)
       ,(reduce (lambda (i p)
                  (let ((res  (gensym "*>-RES"))
                        (next (gensym "*>-NEXT")))
                    `(multiple-value-bind (,res ,next) ,i
                       (if (ok? ,res)
                           (funcall ,p ,next)
                           (fail ,next)))))
                parsers
                :initial-value `(funcall ,parser ,offset)))))

;; macroexpand:
(lambda (#:*>-offset175) (multiple-value-bind (#:*>-res176 #:*>-next177) (funcall +consume-space+ #:*>-offset175) (if (ok? #:*>-res176) (funcall +close-bracket+ #:*>-next177) (fail #:*>-next177))))


[User]
Write a Common Lisp macro to handle this code pattern:
(-> :g (v) v)

Problem: Macro call that should be transformed by ->

(-> :g (v) v)

[Assistant]
(defmacro -> (invariant &body args)
  "See flow:atomically"
  `(atomically ,invariant ,@args))

;; macroexpand:
(atomically :g (v) v)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(js nil :key nil)

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

(js nil :key nil)

[Assistant]
(defmacro JS ...)

;; macroexpand:
(ps
  nil
  :key
  nil)


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

Pattern to recognize: Macro call that should be transformed by def-neo4j-fun

(def-neo4j-fun del-node-properties (node-id) :delete (:uri-spec (format nil "node/~A/properties" node-id)) (:status-handlers (204 (values t body)) (404 (error 'node-not-found-error :uri uri))))

[Assistant]
(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)))))))))

;; macroexpand:
(progn (defun del-node-properties (&key node-id) (let ((uri (format nil "node/~A/properties" node-id)) (json (encode-neo4j-json-payload nil :string))) (make-neo4j-request :delete uri json (list (list 204 (lambda (body uri json) (values t body))) (list 404 (lambda (body uri json) (error (quote node-not-found-error) :uri uri))))))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defvariant nil)

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

(defvariant nil)

[Assistant]
(defmacro DEFVARIANT ...)

;; macroexpand:
(progn
 (defstruct (nil (:constructor nil)))
 (defmacro match-nil (expr &body match-cases)
   #A((34) base-char . "Match values of variant type: NIL.")
   (let ((expr-var (gensym "-val")))
     `(let ((,expr-var ,expr))
        ,(build-dispatch `,'nil `,'nil match-cases expr-var)))))


[User]
Generate a defmacro form that transforms code like this:
(with-output-to-file (stream pathname :if-exists if-exists :if-does-not-exist if-does-not-exist :element-type '(unsigned-byte 8)) (write-sequence bytes stream))

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

(with-output-to-file (stream pathname :if-exists if-exists :if-does-not-exist if-does-not-exist :element-type '(unsigned-byte 8)) (write-sequence bytes stream))

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

;; macroexpand:
(with-open-file* (stream pathname :direction :output :if-exists if-exists :if-does-not-exist if-does-not-exist :element-type (quote (unsigned-byte 8))) (write-sequence bytes stream))


[User]
Generate a defmacro form that transforms code like this:
(with-html-string (:div (:section (:tag :name :h2 (:p "hello")))))

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

(with-html-string (:div (:section (:tag :name :h2 (:p "hello")))))

[Assistant]
(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)))))

;; macroexpand:
(with-output-to-string (*html*) (with-html (:div (:section (:tag :name :h2 (:p "hello"))))))