j14i/cl-macros huggingface dataset:
You are a Common Lisp macro expert. Given this code pattern:
(action (:after node-application node) (when (eq name (node-rator-name node)) (application-with-rator node rator)))

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

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

Macroexpansion:
(make-action (quote :after) (quote node-application) (lambda (node) (declare (type node-application node)) (when (eq name (node-rator-name node)) (application-with-rator node rator))))
Create a Common Lisp macro for the following transformation. Before code:
(with-active-layers* nil)

What needs to change: Macro call that should be transformed by WITH-ACTIVE-LAYERS*

Macro definition:
(defmacro WITH-ACTIVE-LAYERS* ...)

Macroexpansion:
(progn)
Generate a defmacro form that transforms code like this:
(deferror "53" insufficient-resources)

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

Macro definition:
(defmacro deferror (code typename &optional (superclass 'database-error))
  `(progn (define-condition ,typename (,superclass) ())
          (setf (gethash ,code *error-table*) ',typename)))

Macroexpansion:
(progn (define-condition insufficient-resources (database-error) nil) (setf (gethash "53" *error-table*) (quote insufficient-resources)))
Write a Common Lisp macro to handle this code pattern:
(defun/1 rename (oldname newname) (handler-case (progn (rename-file oldname newname) 0) (file-error () 1)))

Problem: Macro call that should be transformed by defun/1

Macro definition:
(defmacro defun/1 (name arglist &body body)
  "Lisp-1 defun; makes function pointers work."
  `(progn
     (defun ,name ,arglist
       (declare (optimize (speed 0) (debug 3)
                          ;; FIXME: Why do minor warnings result in load errors?
                          #+sbcl (sb-ext:inhibit-warnings 3)))
        
       ,@body)
     (defparameter ,name (vacietis.c:mkptr& (symbol-function ',name)))))

Macroexpansion:
(progn (defun rename (oldname newname) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (handler-case (progn (rename-file oldname newname) 0) (file-error nil 1))) (defparameter rename (vacietis.c:mkptr& (symbol-function (quote rename)))))
Generate a defmacro form that transforms code like this:
(~> (-> :one () (increment)) (-> :one () (increment)) (-> :one () (increment)))

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

Macro definition:
(defmacro ~> (&rest body)
  "See flow:concurrently"
  `(concurrently ,@body))

Macroexpansion:
(concurrently (-> :one nil (increment)) (-> :one nil (increment)) (-> :one nil (increment)))
You are a Common Lisp macro expert. Given this code pattern:
(defparameter* nil (progn))

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

Macro definition:
(defmacro DEFPARAMETER* ...)

Macroexpansion:
(defvar/param defparameter nil (progn) nil)
Create a Common Lisp macro for the following transformation. Before code:
(with-inactive-layers nil
  nil)

What needs to change: Macro call that should be transformed by WITH-INACTIVE-LAYERS

Macro definition:
(defmacro WITH-INACTIVE-LAYERS ...)

Macroexpansion:
(progn nil)
Define a macro that eliminates this repetitive pattern:
(some-<>)

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

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

Macroexpansion:
nil
Generate a defmacro form that transforms code like this:
(define-language nil (progn))

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

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

Macroexpansion:
(progn
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (defclass nil ((progn)) nil))
 (define-language-macro nil))
Write a Common Lisp macro to handle this code pattern:
(iterate
  nil
  nil)

Problem: Macro call that should be transformed by ITERATE

Macro definition:
(defmacro ITERATE ...)

Macroexpansion:
(iter
  nil
  nil)
Define a macro that eliminates this repetitive pattern:
(-> nil)

Issue: Macro call that should be transformed by ->

Macro definition:
(defmacro -> ...)

Macroexpansion:
nil
Create a Common Lisp macro for the following transformation. Before code:
(when (and (eql (length nodes) 1) (typep (first nodes) 'expression-statement) (typep (slot-value (first nodes) 'expression) 'nodelist)) (setf nodes (slot-value (slot-value (first nodes) 'expression) 'nodes)))

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

Macro definition:
(defmacro when (test &body forms)
  `(if ,test
	   ,(cl:if (cadr forms)
			   `(progn ,@forms)
			   (car forms))))

Macroexpansion:
(if (and (eql (length nodes) 1) (typep (first nodes) (quote expression-statement)) (typep (slot-value (first nodes) (quote expression)) (quote nodelist))) (setf nodes (slot-value (slot-value (first nodes) (quote expression)) (quote nodes))))
Create a Common Lisp macro for the following transformation. Before code:
(count-of nil)

What needs to change: Macro call that should be transformed by COUNT-OF

Macro definition:
(defmacro COUNT-OF ...)

Macroexpansion:
(lc (nil) count)
Write a Common Lisp macro to handle this code pattern:
(-<> nil :key nil)

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

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

Macroexpansion:
(-> (:key nil) nil)
Create a Common Lisp macro for the following transformation. Before code:
(c-assert test-fn)

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

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

Macroexpansion:
(unless *stop* (unless test-fn (c-break "failed assertion: ~a" (quote test-fn))))
Create a Common Lisp macro for the following transformation. Before code:
(assert-values ("changed foo = 1") (foo 1) (foo+1 2) (bar 42) (bar-1 41))

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

Macro definition:
(defmacro assert-values ((desc) &body objects-and-values)
  `(progn
     (trc ,desc)
     ,@(loop for (obj val) in objects-and-values
	    collect `(assert (eql (value ,obj) ,val)))))

Macroexpansion:
(progn (trc "changed foo = 1") (assert (eql (value foo) 1)) (assert (eql (value foo+1) 2)) (assert (eql (value bar) 42)) (assert (eql (value bar-1) 41)))
Define a macro that eliminates this repetitive pattern:
(rem-bops nil (progn))

Issue: Macro call that should be transformed by REM-BOPS

Macro definition:
(defmacro REM-BOPS ...)

Macroexpansion:
(eval-when (:load-toplevel :compile-toplevel :execute)
  (progn (save-binfix) (mapc 'rmbop '(nil (progn))) (assign-properties)))
Write a Common Lisp macro to handle this code pattern:
(define-error swizzle-keyword () (item) "Swizzle expects a keyword to specify the components. Recieved ~a instead" item)

Problem: Macro call that should be transformed by define-error

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

Macroexpansion:
(defcondition swizzle-keyword (:error-type varjo-error :prefix "Varjo") (item) "Swizzle expects a keyword to specify the components. Recieved ~a instead" item)
Define a macro that eliminates this repetitive pattern:
(augment code (copy-list (driver-info-next-code di)))

Issue: Macro call that should be transformed by augment

Macro definition:
(defmacro augment (var stuff)
  `(setf ,var (nconc ,var ,stuff)))

Macroexpansion:
(setf code (nconc code (copy-list (driver-info-next-code di))))
Create a Common Lisp macro for the following transformation. Before code:
(define-stealth-mixin nil :key nil)

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

Macro definition:
(defmacro DEFINE-STEALTH-MIXIN ...)

Macroexpansion:
(progn (defclass nil :key) (add-mixin 'nil 'nil))
Write a Common Lisp macro to handle this code pattern:
(define-modf-rewrite caddar (expr) `(car (cddar ,(second expr))))

Problem: Macro call that should be transformed by define-modf-rewrite

Macro definition:
(defmacro define-modf-rewrite (name (expr) &body body)
  "Define a new rewrite rule.  If a form starting with NAME is encountered, call
the defined function to return a form that we can deal with (i.e. one defined
via DEFINE-MODF-EXPANDER, DEFINE-MODF-FUNCTION, and DEFINE-MODF-METHOD)."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (gethash ',name *modf-rewrites*)
           (lambda (,expr)
             ,@body))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote caddar) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (car (cddar #S(sb-impl::comma :expr (second expr) :kind 0)))))))
Create a Common Lisp macro for the following transformation. Before code:
(defmethods-with-setf get-val (object &rest key/s) ((object hash-table) &rest key/s) (gethash (car key/s) object) ((object sequence) &rest key/s) (elt object (car key/s)) ((object structure-object) &rest key/s) (slot-value object (car key/s)) ((object standard-object) &rest key/s) (slot-value object (car key/s)))

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

Macro definition:
(defmacro defmethods-with-setf (fun-name lambda-list &rest methods)
  `(progn
     ,@(let ((new-value (gensym)))
         `(,(let ((methods methods))
              `(defgeneric ,fun-name ,lambda-list
                 ,@(loop for args = (first methods)
                         for body = (second methods)
                         do (setq methods (cddr methods))
                         while methods
                         collect `(:method ,args
                                    (assert (= 1 (length key/s)))
                                    ,body))))
           ,@(let ((methods methods))
               (loop for args = (first methods)
                     for body = (second methods)
                     while methods
                     collect `(defmethod (setf ,fun-name) (,new-value ,@args)
                                (setf ,body ,new-value))
                     do (setq methods (cddr methods))))))))

Macroexpansion:
(progn (defgeneric get-val (object &rest key/s) (:method ((object hash-table) &rest key/s) (assert (= 1 (length key/s))) (gethash (car key/s) object)) (:method ((object sequence) &rest key/s) (assert (= 1 (length key/s))) (elt object (car key/s))) (:method ((object structure-object) &rest key/s) (assert (= 1 (length key/s))) (slot-value object (car key/s)))) (defmethod (setf get-val) (#:g122 (object hash-table) &rest key/s) (setf (gethash (car key/s) object) #:g122)) (defmethod (setf get-val) (#:g122 (object sequence) &rest key/s) (setf (elt object (car key/s)) #:g122)) (defmethod (setf get-val) (#:g122 (object structure-object) &rest key/s) (setf (slot-value object (car key/s)) #:g122)) (defmethod (setf get-val) (#:g122 (object standard-object) &rest key/s) (setf (slot-value object (car key/s)) #:g122)))
You are a Common Lisp macro expert. Given this code pattern:
(defun/1 ftell (fd) (or (file-position (fd-stream fd)) -1))

Write a macro that addresses: Macro call that should be transformed by defun/1

Macro definition:
(defmacro defun/1 (name arglist &body body)
  "Lisp-1 defun; makes function pointers work."
  `(progn
     (defun ,name ,arglist
       (declare (optimize (speed 0) (debug 3)
                          ;; FIXME: Why do minor warnings result in load errors?
                          #+sbcl (sb-ext:inhibit-warnings 3)))
        
       ,@body)
     (defparameter ,name (vacietis.c:mkptr& (symbol-function ',name)))))

Macroexpansion:
(progn (defun ftell (fd) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (or (file-position (fd-stream fd)) -1)) (defparameter ftell (vacietis.c:mkptr& (symbol-function (quote ftell)))))
You are a Common Lisp macro expert. Given this code pattern:
(draw scene (:image :x 10 :y 10 :height 600 :width 600 :xlink-href img-url :mask (xlink-href mask1)))

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

Macro definition:
(defmacro draw (scene (shape &rest params) &rest opts)
  (let ((element (gensym)))
    `(let ((,element (funcall #'make-svg-element ,shape (append (list ,@params) (list ,@opts)))))
       (add-element ,scene ,element)
       ,element)))

Macroexpansion:
(let ((#:g156 (funcall (function make-svg-element) :image (append (list :x 10 :y 10 :height 600 :width 600 :xlink-href img-url :mask (xlink-href mask1)) (list))))) (add-element scene #:g156) #:g156)
Write a Common Lisp macro to handle this code pattern:
(define-element-maker :foreign-object "foreignObject" '(:x :y :height :width))

Problem: Macro call that should be transformed by define-element-maker

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

Macroexpansion:
(progn (defmethod assert-required-attributes ((element (eql :foreign-object)) attributes) (declare (ignore element)) (unless (evenp (length attributes)) (warn "attribute list may be missing data: ~A" attributes)) (let ((missing (set-difference (quote (:x :y :height :width)) attributes))) (when missing (error (quote missing-attributes) :message (format nil "~A missing attributes: ~{~A~^ ~}" :foreign-object missing))))) (defmethod make-svg-element ((element (eql :foreign-object)) attributes) (when *check-required-attributes* (assert-required-attributes element attributes)) (make-instance (quote svg-element) :name "foreignObject" :attributes attributes)))
Create a Common Lisp macro for the following transformation. Before code:
(answer foo 3 (call-previous))

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

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

Macroexpansion:
(if-called (quote foo) (let ((#:g164 (fdefinition (quote foo)))) (declare (ignorable #:g164)) (let ((times 0)) (lambda (&rest args) (declare (ignorable args)) (case (prog1 times (incf times)) (0 3) (t (call-previous)))))))
Create a Common Lisp macro for the following transformation. Before code:
(define-op (:else unary-op))

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

Macro definition:
(defmacro define-op ((op-name struct-type &key sql-op-name include-slots (package (find-package '#:sxql/operator))) &body body)
  (check-type op-name symbol)
  (let ((struct-name (intern (concatenate 'string (symbol-name op-name) #.(string :-op)) package)))
    `(defstruct (,struct-name (:include ,struct-type
                               (name ,(or sql-op-name
                                          (with-output-to-string (s)
                                            (loop for c across (symbol-name op-name)
                                                  if (char= c #\-)
                                                    do (write-char #\Space s)
                                                  else
                                                    do (write-char c s)))))
                               ,@include-slots)
                              (:constructor ,(intern (concatenate 'string
                                                                  #.(string :make-)
                                                                  (symbol-name op-name)
                                                                  #.(string :-op))
                                                     package)
                                  ,(ecase struct-type
                                     ((unary-op
                                       unary-splicing-op
                                       unary-postfix-op) '(var))
                                     ((infix-op
                                       infix-splicing-op
                                       infix-list-op) '(left right))
                                     (conjunctive-op '(&rest expressions)))))
       ,@body)))

Macroexpansion:
(defstruct (else-op (:include unary-op (name "ELSE")) (:constructor make-else-op (var))))
Write a Common Lisp macro to handle this code pattern:
(maybe-once-only nil
  (progn))

Problem: Macro call that should be transformed by MAYBE-ONCE-ONLY

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

Macroexpansion:
(let* ((#:g183 nil))
  `(let* ,(nreverse #:g183)
     ,(progn)))
Define a macro that eliminates this repetitive pattern:
(assert-field 'title object)

Issue: Macro call that should be transformed by assert-field

Macro definition:
(defmacro assert-field (field-name content)
  `(when (not (slot-boundp ,content ,field-name))
     (error 'field-missing
            :field-name ,field-name
            :file (content-file ,content))))

Macroexpansion:
(when (not (slot-boundp object (quote title))) (error (quote field-missing) :field-name (quote title) :file (content-file object)))
Write a Common Lisp macro to handle this code pattern:
(defjsmacro nil)

Problem: Macro call that should be transformed by DEFJSMACRO

Macro definition:
(defmacro DEFJSMACRO ...)

Macroexpansion:
(defpsmacro nil)
You are a Common Lisp macro expert. Given this code pattern:
(defhandler flet (flet bindings &rest body) `(list* ',flet ,(dump-fbindings bindings) (with-imposed-bindings (,flet ,(clean-fbindings bindings) ,(declare-fbindings-ignorable bindings) (m-list ,@body)))))

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

Macro definition:
(defmacro defhandler (symbol lambda-list &body body)
  (let ((syms (force-list symbol)))
    (let ((func (intern (format nil "~A~A" 'hander- (first syms)))))
      `(progn
         (defun ,func ,lambda-list
           ,@body)
         (setf
          ,@(loop for sym in syms
               collect `(gethash ',sym *form-handler*)
               collect `',func))))))

Macroexpansion:
(progn (defun hander-flet (flet bindings &rest body) (sb-int:quasiquote (list* (quote #S(sb-impl::comma :expr flet :kind 0)) #S(sb-impl::comma :expr (dump-fbindings bindings) :kind 0) (with-imposed-bindings (#S(sb-impl::comma :expr flet :kind 0) #S(sb-impl::comma :expr (clean-fbindings bindings) :kind 0) #S(sb-impl::comma :expr (declare-fbindings-ignorable bindings) :kind 0) (m-list #S(sb-impl::comma :expr body :kind 2))))))) (setf (gethash (quote flet) *form-handler*) (quote hander-flet)))
Define a macro that eliminates this repetitive pattern:
(defun/1 remove (filename) (handler-case (progn (delete-file (char*-to-string filename)) 0) (file-error () 1)))

Issue: Macro call that should be transformed by defun/1

Macro definition:
(defmacro defun/1 (name arglist &body body)
  "Lisp-1 defun; makes function pointers work."
  `(progn
     (defun ,name ,arglist
       (declare (optimize (speed 0) (debug 3)
                          ;; FIXME: Why do minor warnings result in load errors?
                          #+sbcl (sb-ext:inhibit-warnings 3)))
        
       ,@body)
     (defparameter ,name (vacietis.c:mkptr& (symbol-function ',name)))))

Macroexpansion:
(progn (defun remove (filename) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (handler-case (progn (delete-file (char*-to-string filename)) 0) (file-error nil 1))) (defparameter remove (vacietis.c:mkptr& (symbol-function (quote remove)))))
You are a Common Lisp macro expert. Given this code pattern:
(true T)

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

Macro definition:
(defmacro true (form &optional description &rest format-args)
  `(eval-in-context
    *context*
    (make-instance 'comparison-result
                   :expression '(true ,form)
                   :value-form ',form
                   :body (lambda () ,form)
                   :expected 'T
                   :comparison 'geq
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))

Macroexpansion:
(eval-in-context *context* (make-instance (quote comparison-result) :expression (quote (true t)) :value-form (quote t) :body (lambda nil t) :expected (quote t) :comparison (quote geq)))