j14i/cl-macros huggingface dataset:
You are a Common Lisp macro expert. Given this code pattern:
(check-cursor-attached cluffer:forward-item (cursor))

Write a macro that addresses: Macro call that should be transformed by check-cursor-attached

Macro definition:
(defmacro check-cursor-attached (name arguments)
  (let ((args (substitute '(cursor cluffer:cursor) 'cursor arguments)))
    `(defmethod ,name :before ,args
       (declare (ignore ,@(set-difference (remove 'cursor arguments)
                                          lambda-list-keywords)))
       (unless (cluffer:cursor-attached-p cursor)
         (error 'cluffer:cursor-detached)))))

Macroexpansion:
(defmethod cluffer:forward-item :before ((cursor cluffer:cursor)) (declare (ignore)) (unless (cluffer:cursor-attached-p cursor) (error (quote cluffer:cursor-detached))))
Create a Common Lisp macro for the following transformation. Before code:
(collect-sum nil)

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

Macro definition:
(defmacro COLLECT-SUM ...)

Macroexpansion:
(common-lisp:let* ((#:generator-236 (generator nil))
                   #:numbers-232
                   (#:sum-233 0))
  (declare (type generator #:generator-236)
           (type number #:sum-233))
  (tagbody
   #:ll-237
    (setq #:numbers-232 (next-in #:generator-236 (go end)))
    (setq #:sum-233 (+ #:sum-233 #:numbers-232))
    (go #:ll-237)
   end)
  #:sum-233)
You are a Common Lisp macro expert. Given this code pattern:
(defsynonym always :always)

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

Macro definition:
(defmacro defsynonym (symbol synonym)
  "Set SYNONYM for a SYMBOL. "
  `(eval-always
     (setf (get ',symbol 'synonym) ',synonym)))

Macroexpansion:
(eval-always (setf (get (quote always) (quote synonym)) (quote :always)))
You are a Common Lisp macro expert. Given this code pattern:
(defun* nil
    nil)

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

Macro definition:
(defmacro DEFUN* ...)

Macroexpansion:
(progn (declaim (ftype (function nil t) nil)) (defun nil (the t ())))
Generate a defmacro form that transforms code like this:
(dict-of nil nil)

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

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

Macroexpansion:
(let ((#:dict125 (make-hash-table :test 'equal)))
  (do-for (nil)
    (multiple-value-call
        (lambda (#:k126 #:v127) (setf (gethash #:k126 #:dict125) #:v127))
      nil))
  #:dict125)
Write a Common Lisp macro to handle this code pattern:
(deferror "42703" undefined-column syntax-error-or-access-violation)

Problem: Macro call that should be transformed by deferror

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

Macroexpansion:
(progn (define-condition undefined-column (syntax-error-or-access-violation) nil) (setf (gethash "42703" *error-table*) (quote undefined-column)))
Create a Common Lisp macro for the following transformation. Before code:
(defun-compile-time cps-convert-let* (bindings body declarations continuation types value? environment) (if (null bindings) (if (null declarations) (cps-convert-progn body continuation types value? environment) `(let () ,@declarations ,(cps-convert-progn body continuation types value? environment))) (let* ((binding (first bindings)) (binding-variable (if (symbolp binding) binding (first binding))) (binding-form (if (and (consp binding) (= (length binding) 2)) (second binding) nil)) (other-arguments (gensym "OTHER-"))) (cps-convert binding-form `#'(lambda (&optional ,binding-variable &rest ,other-arguments) (declare (magic) (ignore ,other-arguments)) ,(cps-convert-let* (rest bindings) body declarations continuation types value? environment)) '() t environment))))

What needs to change: Macro call that should be transformed by defun-compile-time

Macro definition:
(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))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:defun cps-convert-let* (bindings body declarations continuation types value? environment) (if (null bindings) (if (null declarations) (cps-convert-progn body continuation types value? environment) (sb-int:quasiquote (let nil #S(sb-impl::comma :expr declarations :kind 2) #S(sb-impl::comma :expr (cps-convert-progn body continuation types value? environment) :kind 0)))) (let* ((binding (first bindings)) (binding-variable (if (symbolp binding) binding (first binding))) (binding-form (if (and (consp binding) (= (length binding) 2)) (second binding) nil)) (other-arguments (gensym "OTHER-"))) (cps-convert binding-form (sb-int:quasiquote (function (lambda (&optional #S(sb-impl::comma :expr binding-variable :kind 0) &rest #S(sb-impl::comma :expr other-arguments :kind 0)) (declare (magic) (ignore #S(sb-impl::comma :expr other-arguments :kind 0))) #S(sb-impl::comma :expr (cps-convert-let* (rest bindings) body declarations continuation types value? environment) :kind 0)))) (quote nil) t environment)))) (eval-when (:compile-toplevel) (compile (quote cps-convert-let*))))
You are a Common Lisp macro expert. Given this code pattern:
(define-op (:* conjunctive-op))

Write a macro that addresses: 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 (*-op (:include conjunctive-op (name "*")) (:constructor make-*-op (&rest expressions))))
Generate a defmacro form that transforms code like this:
(enable-syntax)

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

Macro definition:
(defmacro enable-syntax ()
  '(in-readtable datafly-syntax))

Macroexpansion:
(in-readtable datafly-syntax)
Create a Common Lisp macro for the following transformation. Before code:
(bind (((:plist (start _ 0) end (fuzz fuzziness 'no)) plist)) (list start end fuzz))

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

Macro definition:
(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))))

Macroexpansion:
(let* ((#:|values-163| plist) (start (getf #:|values-163| :start 0)) (end (getf #:|values-163| :end)) (fuzz (getf #:|values-163| :fuzziness (quote no)))) (declare (ignorable #:|values-163|)) (progn (list start end fuzz)))
Write a Common Lisp macro to handle this code pattern:
(is eql a 'c)

Problem: Macro call that should be transformed by is

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

Macroexpansion:
(eval-in-context *context* (make-instance (quote comparison-result) :expression (quote (is eql a (quote c))) :value-form (quote (quote c)) :body (lambda nil (quote c)) :expected a :comparison (quote eql)))
Write a Common Lisp macro to handle this code pattern:
(define-custom-var (:internal-decoder *internal-decoder*) 'decode-json "Designator for a function of 1 stream argument called (instead of DECODE-JSON) to decode a member of an Array or of an Object.")

Problem: Macro call that should be transformed by define-custom-var

Macro definition:
(defmacro define-custom-var ((key name) &rest other-args)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (progn (pushnew '(,name . ,key) *custom-vars* :test #'equal)
            (defvar ,name ,@other-args))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (pushnew (quote (*internal-decoder* . :internal-decoder)) *custom-vars* :test (function equal)) (defvar *internal-decoder* (quote decode-json) "Designator for a function of 1 stream argument called (instead of DECODE-JSON) to decode a member of an Array or of an Object.")))
Write a Common Lisp macro to handle this code pattern:
(enable-quasi-quoted-string-to-binary-emitting-form-syntax 'some-name)

Problem: Macro call that should be transformed by ENABLE-QUASI-QUOTED-STRING-TO-BINARY-EMITTING-FORM-SYNTAX

Macro definition:
(defmacro ENABLE-QUASI-QUOTED-STRING-TO-BINARY-EMITTING-FORM-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-quasi-quoted-string-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 "str" :encoding *default-character-encoding*)
  (values))
Create a Common Lisp macro for the following transformation. Before code:
(defpackage nil (progn))

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

Macro definition:
(defmacro DEFPACKAGE ...)

Macroexpansion:
(common-lisp:defpackage nil
  (:use :adhoc :closer-mop :cl)
  (:shadowing-import-from :closer-mop
                          #:defmethod
                          #:standard-generic-function
                          #:defgeneric
                          #:standard-method
                          #:standard-class)
  (:shadowing-import-from :adhoc #:defpackage #:variable #:the)
  (progn))
Define a macro that eliminates this repetitive pattern:
(with-rules nil
  :key
  nil)

Issue: Macro call that should be transformed by WITH-RULES

Macro definition:
(defmacro WITH-RULES ...)

Macroexpansion:
(dolist (nil (alexandria:hash-table-keys cl-rules.core::*rules*)) :key nil)
Create a Common Lisp macro for the following transformation. Before code:
(some->>
  nil
  :key
  nil)

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

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

Macroexpansion:
(let* ((#:var201 nil)
       (#:var202
        (if #:var201
            (:key #:var201)
            nil))
       (#:var203
        (if #:var202
            (nil #:var202)
            nil)))
  #:var203)
Write a Common Lisp macro to handle this code pattern:
(defun/1 putchar (c) (fputc c stdout))

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 putchar (c) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (fputc c stdout)) (defparameter putchar (vacietis.c:mkptr& (symbol-function (quote putchar)))))
Generate a defmacro form that transforms code like this:
(matrix-case 'some-name)

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

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

Macroexpansion:
(let ((#:g247 quote))
  (case #:g247))
Create a Common Lisp macro for the following transformation. Before code:
(defreply nil
    nil)

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

Macro definition:
(defmacro DEFREPLY ...)

Macroexpansion:
(progn
 (eval-when (:compile-toplevel)
   (unless (fboundp 'nil)
     (warn 'automatic-message-creation :message-name 'nil)
     (ensure-message 'nil :lambda-list 'nil)))
 (ensure-reply 'nil :qualifiers 'nil :lambda-list 'nil :participants (list)
               :documentation nil :function
               (lambda (#:args136 #:next-replies137 &rest #:more-args139)
                 (declare
                  (ignorable #:args136 #:next-replies137 #:more-args139))
                 (flet ((next-reply-p ()
                          (not (null #:next-replies137)))
                        (call-next-reply (&rest args)
                          (if (null #:next-replies137)
                              (apply 'no-next-reply
                                     (getf #:more-args139 :message)
                                     (getf #:more-args139 :reply)
                                     (or args #:args136))
                              (apply (reply-function (car #:next-replies137))
                                     (or args #:args136)
                                     (cdr #:next-replies137) #:more-args139))))
                   (declare
                    (ignorable (function next-reply-p)
                     (function call-next-reply)))
                   (flet ((#:reply-function138 ()
                            (declare (ignorable))
                            (block nil)))
                     (declare (inline #:reply-function138))
                     (apply #'#:reply-function138 #:args136))))))
Generate a defmacro form that transforms code like this:
(*> #'integer (opt (*> (char #\.) (take-while1 #'digit?))))

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

Macro definition:
(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)))))

Macroexpansion:
(lambda (#:*>-offset215) (multiple-value-bind (#:*>-res216 #:*>-next217) (funcall (function integer) #:*>-offset215) (if (ok? #:*>-res216) (funcall (opt (*> (char #\FULL_STOP) (take-while1 (function digit?)))) #:*>-next217) (fail #:*>-next217))))
Define a macro that eliminates this repetitive pattern:
(with-html-string (:xy "Hello"))

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

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

Macroexpansion:
(with-output-to-string (*html*) (with-html (:xy "Hello")))
Write a Common Lisp macro to handle this code pattern:
(maybe-once-only nil
  nil)

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

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

Macroexpansion:
(let* ((#:g182 nil))
  `(let* ,(nreverse #:g182)
     ,nil))
Write a Common Lisp macro to handle this code pattern:
(flow-lambda-macro (flow-context) (with-flow-function-macro (body-fu lambda-list body) `(dispatch-dynamically ,flow-context #',body-fu)))

Problem: Macro call that should be transformed by flow-lambda-macro

Macro definition:
(defmacro flow-lambda-macro ((flow-context) &body body)
  `(with-gensyms (,flow-context)
     `(%flow-lambda (,,flow-context)
        ,,@body)))

Macroexpansion:
(with-gensyms (flow-context) (sb-int:quasiquote (%flow-lambda (#S(sb-impl::comma :expr flow-context :kind 0)) #S(sb-impl::comma :expr (with-flow-function-macro (body-fu lambda-list body) (sb-int:quasiquote (dispatch-dynamically #S(sb-impl::comma :expr flow-context :kind 0) (function #S(sb-impl::comma :expr body-fu :kind 0))))) :kind 0))))
Generate a defmacro form that transforms code like this:
(define-element-maker :radial-gradient "radialGradient" '(:id :cx :cy :r))

Pattern to recognize: 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 :radial-gradient)) attributes) (declare (ignore element)) (unless (evenp (length attributes)) (warn "attribute list may be missing data: ~A" attributes)) (let ((missing (set-difference (quote (:id :cx :cy :r)) attributes))) (when missing (error (quote missing-attributes) :message (format nil "~A missing attributes: ~{~A~^ ~}" :radial-gradient missing))))) (defmethod make-svg-element ((element (eql :radial-gradient)) attributes) (when *check-required-attributes* (assert-required-attributes element attributes)) (make-instance (quote svg-element) :name "radialGradient" :attributes attributes)))
Define a macro that eliminates this repetitive pattern:
(with-context (context) (process-response this result))

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

Macro definition:
(defmacro with-context ((context) &body body)
  `(let* ((*context* ,context)
          (*request* (context :request))
          (*response* (context :response))
          (*session* (context :session)))
     ,@body))

Macroexpansion:
(let* ((*context* context) (*request* (context :request)) (*response* (context :response)) (*session* (context :session))) (process-response this result))
Write a Common Lisp macro to handle this code pattern:
(def-neo4j-fun query-index ((type :node) name query) :get (:uri-spec (format nil "index/~A/~A/?query=~A" (string-downcase (symbol-name type)) name (urlencode query))) (:status-handlers (200 (decode-neo4j-json-output body)) (404 (error 'index-entry-not-found-error :uri uri))))

Problem: Macro call that should be transformed by def-neo4j-fun

Macro definition:
(defmacro def-neo4j-fun (name lambda-list method &rest args)
  `(progn
     (defun ,name (&key ,@lambda-list)
       (let ((uri ,(cadr (assoc :uri-spec args)))
             (json (encode-neo4j-json-payload ,@(aif (assoc :encode args)
                                                     (cdr it)
                                                     (list '() :string)))))
         (make-neo4j-request ,method uri json
                             (list ,@(mapcar (lambda (handler)
                                               `(list ,(car handler) (lambda (body uri json)
                                                                  ,(cadr handler))))
                                             (cdr (assoc :status-handlers args)))))))))

Macroexpansion:
(progn (defun query-index (&key (type :node) name query) (let ((uri (format nil "index/~A/~A/?query=~A" (string-downcase (symbol-name type)) name (urlencode query))) (json (encode-neo4j-json-payload nil :string))) (make-neo4j-request :get uri json (list (list 200 (lambda (body uri json) (decode-neo4j-json-output body))) (list 404 (lambda (body uri json) (error (quote index-entry-not-found-error) :uri uri))))))))