j14i/cl-macros huggingface dataset:
Generate a defmacro form that transforms code like this:
(with-color (:yellow :stream stream) (format/indent reporter stream "△ Looks like you planned ~D test~:*~P but ran ~A.~%" plan count))

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

Macro definition:
(defmacro with-color ((color &rest args) &body body)
  (cond
    ((or (eq color :gray)
         (eq color :grey))
     `(if *enable-colors*
          (with-gray ,(or (getf args :stream) t) ,@body)
          (progn ,@body)))
    (T `(if *enable-colors*
            (if (or (eq ,color :gray)
                    (eq ,color :grey)
                    (eq ,color cl-colors:+gray+)
                    (eq ,color cl-colors:+grey+))
                (with-gray ,(or (getf args :stream) t) ,@body)
                (cl-ansi-text:with-color (,color ,@args) ,@body))
            (progn ,@body)))))

Macroexpansion:
(if *enable-colors* (if (or (eq :yellow :gray) (eq :yellow :grey) (eq :yellow +gray+) (eq :yellow +grey+)) (with-gray stream (format/indent reporter stream "△ Looks like you planned ~D test~:*~P but ran ~A.~%" plan count)) (cl-ansi-text:with-color (:yellow :stream stream) (format/indent reporter stream "△ Looks like you planned ~D test~:*~P but ran ~A.~%" plan count))) (progn (format/indent reporter stream "△ Looks like you planned ~D test~:*~P but ran ~A.~%" plan count)))
You are a Common Lisp macro expert. Given this code pattern:
(enable-quasi-quoted-binary-syntax)

Write a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BINARY-SYNTAX

Macro definition:
(defmacro ENABLE-QUASI-QUOTED-BINARY-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-quasi-quoted-binary-syntax-in-readtable :start-character nil
                                               :end-character nil
                                               :unquote-character #\COMMA
                                               :splice-character
                                               #\COMMERCIAL_AT
                                               :destructive-splice-character
                                               #\FULL_STOP
                                               :dispatched-quasi-quote-name
                                               "bin" :transformation-pipeline
                                               nil)
  (values))
Create a Common Lisp macro for the following transformation. Before code:
(defsynonym :minimizing :min)

What needs to change: 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 :minimizing) (quote synonym)) (quote :min)))
Define a macro that eliminates this repetitive pattern:
(with-html-string (:a :href "#" :data-instant nil))

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 (:a :href "#" :data-instant nil)))
Generate a defmacro form that transforms code like this:
(let-syntax 'some-name)

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

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

Macroexpansion:
(letrec-syntax (common-lisp:quote) (let-syntax (some-name)))
You are a Common Lisp macro expert. Given this code pattern:
($op* op l)

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

Macro definition:
(defmacro $op (op &rest args)
  (cond ((consp (car args)) `(map-reduce-op ,op ($exp+ ,@args)))
	(t                   `($op* ,op ,@args))))

Macroexpansion:
(multiple-value-bind (#:g325 #:g328) (op-split (unwrap (list ($exp+ l)))) (let ((#:g327 (kv (car #:g325) (kv op #:g328)))) (dolist (#:g326 (cdr #:g325)) (setf #:g327 (kv #:g327 (kv #:g326 (kv op #:g328))))) #:g327))
Generate a defmacro form that transforms code like this:
(define-global-parameter nil nil)

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

Macro definition:
(defmacro DEFINE-GLOBAL-PARAMETER ...)

Macroexpansion:
(progn
 (store-in-symbol-plist nil nil .value-key.)
 (sb-ext:defglobal nil (get 'nil +value-key+))
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (setf nil (get 'nil +value-key+)))
 (remprop 'nil +value-key+)
 'nil)
Write a Common Lisp macro to handle this code pattern:
(with-access nil
    nil)

Problem: Macro call that should be transformed by WITH-ACCESS

Macro definition:
(defmacro with-access ((&rest keys) val-form &body body)
  "Similar to with-accessors except using the access functions"
  (let* ((gval (gensym "val"))
     (forms
      (iter (for k in keys)
        (for (k-to k-from) = (if (listp k) k (list k k)))
        (collect `(,k-to (access ,gval ',k-from))))))
    `(let ((,gval ,val-form))
       (declare (ignorable ,gval))
       (symbol-macrolet (,@forms)
     ,@body
     ))))

Macroexpansion:
(let ((#:|val241| nil))
  (declare (ignorable #:|val241|))
  (symbol-macrolet ()))
Generate a defmacro form that transforms code like this:
($> "l" -9)

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

Macro definition:
(defmacro $ (&rest args)
  `(kv ,@args))

Macroexpansion:
($op "$gt" "l" -9)
Define a macro that eliminates this repetitive pattern:
(define-value-binding in (var list &key (by NIL by-p)) (declare (type list list)) `(cond (,list ,(if by-p `(progn (update ,var (car ,list)) (setf ,list (funcall ,by ,list))) `(update ,var (pop ,list)))) (T (end-for))))

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

Macro definition:
(defmacro define-value-binding (name (var &rest args) &body body)
  (let ((vars (lambda-fiddle:extract-lambda-vars (lambda-fiddle:remove-aux-part args))))
    (emit-binding-definition name var args body :extra-vars vars)))

Macroexpansion:
(define-direct-binding in (var list &key (by nil by-p)) (let ((#:list134 (gensym #A((4) base-char . "LIST"))) (#:by135 (gensym #A((2) base-char . "BY")))) (values* (sb-int:quasiquote (with-interleaving (let* #S(sb-impl::comma :expr (list* (list #:list134 list) (list #:by135 by) (loop for #:var133 in (lambda-fiddle:extract-lambda-vars (enlist var)) collect (list #:var133 nil))) :kind 0) (declare (ignorable #S(sb-impl::comma :expr #:list134 :kind 0) #S(sb-impl::comma :expr #:by135 :kind 0))) #S(sb-impl::comma :expr (sb-int:quasiquote (declare (type #S(sb-impl::comma :expr (quote list) :kind 0) #S(sb-impl::comma :expr #:list134 :kind 0)))) :kind 0)) #S(sb-impl::comma :expr nil :kind 0))) (let ((list #:list134) (by #:by135)) (declare (ignorable list by)) (sb-int:quasiquote (cond (#S(sb-impl::comma :expr list :kind 0) #S(sb-impl::comma :expr (if by-p (sb-int:quasiquote (progn (update #S(sb-impl::comma :expr var :kind 0) (car #S(sb-impl::comma :expr list :kind 0))) (setf #S(sb-impl::comma :expr list :kind 0) (funcall #S(sb-impl::comma :expr by :kind 0) #S(sb-impl::comma :expr list :kind 0))))) (sb-int:quasiquote (update #S(sb-impl::comma :expr var :kind 0) (pop #S(sb-impl::comma :expr list :kind 0))))) :kind 0)) (t (end-for))))))))
Write a Common Lisp macro to handle this code pattern:
(collect-nth nil :key nil)

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

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

Macroexpansion:
(common-lisp:let* ((#:generator-420 (generator :key))
                   #:items-412
                   (#:counter-414 nil)
                   (#:item-415 nil))
  (declare (type generator #:generator-420)
           (type (null-or fixnum) #:counter-414)
           (type (null-or t) #:item-415))
  (tagbody
   #:ll-421
    (setq #:items-412 (next-in #:generator-420 (go end)))
    (when (zerop #:counter-414) (setq #:item-415 #:items-412) (go end))
    (decf #:counter-414)
    (go #:ll-421)
   end)
  #:item-415)
Define a macro that eliminates this repetitive pattern:
(pop-preprocessor-directive-token token-list :|_Pragma|)

Issue: Macro call that should be transformed by pop-preprocessor-directive-token

Macro definition:
(defmacro pop-preprocessor-directive-token (token-list directive-name &key (errorp t))
  "Pops the next token in TOKEN-LIST ignoring `+whitespace-marker+'"
  (with-gensyms (head_)
    `(let ((,head_
             (check-and-pop-pp-directive-token-1 ,token-list ,directive-name ,errorp)))
       (if (eq +whitespace-marker+ ,head_)
           (check-and-pop-pp-directive-token-1 ,token-list ,directive-name ,errorp)
           ,head_))))

Macroexpansion:
(let ((#:head_268 (check-and-pop-pp-directive-token-1 token-list :|_Pragma| t))) (if (eq +whitespace-marker+ #:head_268) (check-and-pop-pp-directive-token-1 token-list :|_Pragma| t) #:head_268))
You are a Common Lisp macro expert. Given this code pattern:
(loop 'some-name)

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

Macro definition:
(defmacro LOOP ...)

Macroexpansion:
(block nil (tagbody #:g191 (progn 'some-name) (go #:g191)))
Create a Common Lisp macro for the following transformation. Before code:
(define-errno-symbol EILSEQ)

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

Macro definition:
(defmacro define-errno-symbol (name)
  `(defparameter ,name
     (find-errno-symbol (string ',name))))

Macroexpansion:
(defparameter eilseq (find-errno-symbol (string (quote eilseq))))
Define a macro that eliminates this repetitive pattern:
(destructuring-case 'some-name)

Issue: Macro call that should be transformed by DESTRUCTURING-CASE

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

Macroexpansion:
(destructuring-case-alt 'some-name)
Generate a defmacro form that transforms code like this:
(define-test bad-dependency :depends-on (failing) (is = 5 5))

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

Macro definition:
(defmacro define-test (name &body arguments-and-body)
  (destructuring-bind (nparent name) (if (listp name) name (list NIL name))
    (form-fiddle:with-body-options (body options parent home (test-class 'test) (compile-at :compile-time) defun) arguments-and-body
      (let ((body (remove 'define-test body :key (lambda (a) (when (listp a) (car a))) :test #'eql))
            (defs (remove 'define-test body :key (lambda (a) (when (listp a) (car a))) :test-not #'eql))
            (home-form (or home `(find-package ,(package-name *package*)))))
        (when (and parent nparent)
          (error "Cannot specify parent through name and through a keyword argument at the same time!"))
        `(let ((*package* (find-package ,(package-name *package*)))) ; Make sure package stays consistent throughout initialisation.
           (setf (find-test ',name ,home-form)
                 (ensure-test ',test-class
                              :name ',name
                              :home ,home-form
                              :tests (list ,@(loop for form in body
                                                   collect (ecase compile-at
                                                             (:compile-time `(lambda () ,form))
                                                             (:execute `(lambda () (call-compile ',form))))))
                              :parent ',(or parent nparent)
                              ,@(loop for option in options
                                      collect `',option)))
           ,@(loop for (def subname . body) in defs
                   collect `(,def (,name ,subname)
                              :home ,home
                              ,@body))
           ,@(when defun
               `((defun ,(if (stringp name) (read-symbol name) name) (&rest test-args)
                   (apply #'test (find-test ',name ,home-form) test-args))))
           ',name)))))

Macroexpansion:
(let ((*package* (find-package #A((9) base-char . "PARACHUTE")))) (setf (find-test (quote bad-dependency) (find-package #A((9) base-char . "PARACHUTE"))) (ensure-test (quote test) :name (quote bad-dependency) :home (find-package #A((9) base-char . "PARACHUTE")) :tests (list (lambda nil (is = 5 5))) :parent (quote nil) (quote :depends-on) (quote (failing)))) (quote bad-dependency))
Create a Common Lisp macro for the following transformation. Before code:
(signal-syntax-error* open-paren-pos "Opening paren has no matching closing paren.")

What needs to change: Macro call that should be transformed by signal-syntax-error*

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

Macroexpansion:
(error (quote ppcre-syntax-error) :pos open-paren-pos :format-control "Opening paren has no matching closing paren." :format-arguments (list))
Generate a defmacro form that transforms code like this:
(dflet ((list ())) (is (eql 42 (list))))

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

Macro definition:
(defmacro dflet ((&rest definitions) &body body)
  "Like FLET, but dynamically sets the FDEFINITIONS during the duration of
the BODY."
  `(progf
       ',(mapcar #'car definitions)
       (list
        ,.(mapcar (lambda (definition)
                    `(lambda ,(cadr definition)
                       ,@(cddr definition)))
                  definitions))
     ,@body))

Macroexpansion:
(progf (quote (list)) (list (lambda nil)) (is (eql 42 (list))))
Write a Common Lisp macro to handle this code pattern:
(define-option-expander nicknames (package &rest nicknames) (loop for nick in nicknames do (add-package-nickname package nick)))

Problem: Macro call that should be transformed by define-option-expander

Macro definition:
(defmacro define-option-expander (name (package &rest arguments) &body body)
  (let ((args (gensym "ARGS")))
    `(defmethod expand-option ((,(gensym "TYPE") (eql ,(intern (string name) "KEYWORD"))) ,package ,args)
       (destructuring-bind ,arguments ,args
         ,@body))))

Macroexpansion:
(defmethod expand-option ((#:type122 (eql :nicknames)) package #:args121) (destructuring-bind (&rest nicknames) #:args121 (loop for nick in nicknames do (add-package-nickname package nick))))
Write a Common Lisp macro to handle this code pattern:
(with-connection (let ((user (retrieve-one :user :by :name := "nitro_idiot"))) (is-type user 'trivial-types:property-list)) (let ((user (retrieve-one :user :by :name := "nitro_idiot" :as 'hash-table))) (is-type user 'hash-table)) (let* ((*default-row-type* 'hash-table) (user (retrieve-one :user :by :name := "nitro_idiot"))) (is-type user 'hash-table)) (let* ((*default-row-type* 'hash-table) (user (retrieve-one :user :by :name := "nitro_idiot" :as 'trivial-types:association-list))) (is-type user 'trivial-types:association-list)))

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

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

Macroexpansion:
(let ((let (connect ((user (retrieve-one :user :by :name := "nitro_idiot"))) (is-type user (quote trivial-types:property-list))))) (unwind-protect (progn (let ((user (retrieve-one :user :by :name := "nitro_idiot" :as (quote hash-table)))) (is-type user (quote hash-table))) (let* ((*default-row-type* (quote hash-table)) (user (retrieve-one :user :by :name := "nitro_idiot"))) (is-type user (quote hash-table))) (let* ((*default-row-type* (quote hash-table)) (user (retrieve-one :user :by :name := "nitro_idiot" :as (quote trivial-types:association-list)))) (is-type user (quote trivial-types:association-list)))) (disconnect let)))
Write a Common Lisp macro to handle this code pattern:
(with-unique-names (s-indicator current-s-indicator) (defmacro symbolic (operation test &rest other-args) (with-unique-names (this-s) (let ((current-s (get s-indicator current-s-indicator))) (setf (get s-indicator current-s-indicator) this-s) `(symbol-macrolet ((,this-s (internal-symbol-macrolet ((it ,current-s)) ,test)) (it ,this-s)) (,operation it ,@other-args))))) (defmacro anaphoric (op test &body body) (with-unique-names (this-s) (setf (get s-indicator current-s-indicator) this-s) `(let* ((it ,test) (,this-s it)) (declare (ignorable ,this-s)) (,op it ,@body)))))

Problem: Macro call that should be transformed by with-unique-names

Macro definition:
(defmacro with-unique-names ((&rest bindings) &body body)
  `(let ,(mapcar #'(lambda (binding)
		     (destructuring-bind (var prefix)
			 (if (consp binding) binding (list binding binding))
		       `(,var (gensym ,(string prefix)))))
		 bindings)
     ,@body))

Macroexpansion:
(let ((s-indicator (gensym #A((12) base-char . "S-INDICATOR-"))) (current-s-indicator (gensym #A((20) base-char . "CURRENT-S-INDICATOR-")))) (defmacro symbolic (operation test &rest other-args) (with-unique-names (this-s) (let ((current-s (get s-indicator current-s-indicator))) (setf (get s-indicator current-s-indicator) this-s) (quasiquote (symbol-macrolet ((#S(sb-impl::comma :expr this-s :kind 0) (internal-symbol-macrolet ((it #S(sb-impl::comma :expr current-s :kind 0))) #S(sb-impl::comma :expr test :kind 0))) (it #S(sb-impl::comma :expr this-s :kind 0))) (#S(sb-impl::comma :expr operation :kind 0) it #S(sb-impl::comma :expr other-args :kind 2))))))) (defmacro anaphoric (op test &body body) (with-unique-names (this-s) (setf (get s-indicator current-s-indicator) this-s) (quasiquote (let* ((it #S(sb-impl::comma :expr test :kind 0)) (#S(sb-impl::comma :expr this-s :kind 0) it)) (declare (ignorable #S(sb-impl::comma :expr this-s :kind 0))) (#S(sb-impl::comma :expr op :kind 0) it #S(sb-impl::comma :expr body :kind 2)))))))
You are a Common Lisp macro expert. Given this code pattern:
(define-simple-type-map setf-expander cl:setf)

Write a macro that addresses: Macro call that should be transformed by define-simple-type-map

Macro definition:
(defmacro define-simple-type-map (class type)
  `(defmethod type ((,class ,class))
     ',type))

Macroexpansion:
(defmethod type ((setf-expander setf-expander)) (quote setf))
Write a Common Lisp macro to handle this code pattern:
(ematch0 list ((cons it nil) (cons (funcall fn it nil) nil)) ((cons it rest) (cons (funcall fn it t) (mapcar1-with-next fn rest))))

Problem: Macro call that should be transformed by ematch0

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

Macroexpansion:
(match0 list ((cons it nil) (cons (funcall fn it nil) nil)) ((cons it rest) (cons (funcall fn it t) (mapcar1-with-next fn rest))) (_ (error "level0 match error!")))
Define a macro that eliminates this repetitive pattern:
(*> +table-open+ +skip-space+)

Issue: 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 (#:*>-offset230) (multiple-value-bind (#:*>-res231 #:*>-next232) (funcall +table-open+ #:*>-offset230) (if (ok? #:*>-res231) (funcall +skip-space+ #:*>-next232) (fail #:*>-next232))))
Generate a defmacro form that transforms code like this:
(lambda-cmatch (PATTERN BODY...))

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

Macro definition:
(defmacro lambda-cmatch (&body clauses)
  "Equivalent to (lambda (arg) (cmatch arg CLAUSES...))."
  (with-unique-names (arg)
    `(lambda (,arg) (cmatch ,arg ,@clauses))))

Macroexpansion:
(lambda (#:arg124) (cmatch #:arg124 (pattern body...)))
Write a Common Lisp macro to handle this code pattern:
(rte-ecase 'some-name)

Problem: Macro call that should be transformed by RTE-ECASE

Macro definition:
(defmacro RTE-ECASE ...)

Macroexpansion:
(let ((#:rte172 'some-name))
  (rte-ecase #:rte172
    ((:* t) (error "The sequence ~A fell through the RTE-ECASE" #:rte172))))
Define a macro that eliminates this repetitive pattern:
(define-modf-function last 1 (new-val obj) (let ((len (length obj))) (replace-nthcdr (- len 1) obj new-val)))

Issue: Macro call that should be transformed by define-modf-function

Macro definition:
(defmacro define-modf-function (name nth-arg (new-val &rest args) &body body)
  "Define a new modf function.  It inverts NAME forms by modifying the NTH-ARG
term of the arguments of the place form in the MODF macro."
  ;; Side effect in a macro, I know.  How can you do this via EVAL-WHEN if I
  ;; want it to run even if not a toplevel macro?
  (setf (gethash name *modf-nth-arg*)
        nth-arg)
  `(progn
     (eval-when (:compile-toplevel :load-toplevel :execute)
       (setf (gethash ',name *modf-nth-arg*)
             ,nth-arg))
     (defun ,(intern (modf-name name) :modf) (,new-val ,@args)
       ,@body)))

Macroexpansion:
(progn (eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote last) *modf-nth-arg*) 1)) (defun |BUILDER:COMMON-LISP:LAST| (new-val obj) (let ((len (length obj))) (replace-nthcdr (- len 1) obj new-val))))
Write a Common Lisp macro to handle this code pattern:
(defun-compile-time callees (function-name) (function-record-callees (get-function-record function-name)))

Problem: 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 callees (function-name) (function-record-callees (get-function-record function-name))) (eval-when (:compile-toplevel) (compile (quote callees))))
Define a macro that eliminates this repetitive pattern:
(action (:after node-application) #'apply-candidate)

Issue: 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) (function apply-candidate))