j14i/cl-macros huggingface dataset:
Generate a defmacro form that transforms code like this:
(c?-with-stored (v :bar store 'nothing) (bwhen (val (value v)) val))

Pattern to recognize: Macro call that should be transformed by c?

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

Macroexpansion:
(c? (bwhen-c-stored (v :bar store (quote nothing)) (bwhen (val (value v)) val)))
Create a Common Lisp macro for the following transformation. Before code:
(drelet nil
  (progn))

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

Macro definition:
(defmacro DRELET ...)

Macroexpansion:
(dynamic-relet nil
  (progn))
Generate a defmacro form that transforms code like this:
(defun/1 gets (str) (fgets-is-dumb str most-positive-fixnum stdin t))

Pattern to recognize: 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 gets (str) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (fgets-is-dumb str most-positive-fixnum stdin t)) (defparameter gets (vacietis.c:mkptr& (symbol-function (quote gets)))))
Create a Common Lisp macro for the following transformation. Before code:
(mvlet nil
  nil)

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

Macro definition:
(defmacro MVLET ...)

Macroexpansion:
(progn nil)
You are a Common Lisp macro expert. Given this code pattern:
(dynamic-relet* nil)

Write a macro that addresses: Macro call that should be transformed by DYNAMIC-RELET*

Macro definition:
(defmacro DYNAMIC-RELET* ...)

Macroexpansion:
(progn)
You are a Common Lisp macro expert. Given this code pattern:
(some-> nil :key nil)

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

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

Macroexpansion:
(let* ((#:g144 nil)
       (#:g144
        (if (null #:g144)
            nil
            (-> #:g144 :key))))
  (if (null #:g144)
      nil
      (-> #:g144 nil)))
You are a Common Lisp macro expert. Given this code pattern:
(define-library libwinpthread)

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

Macro definition:
(defmacro define-library (name &body initargs)
  #+cffi
  `(change-class (cffi::get-foreign-library ',name)
                 'library
                 ,@initargs)
  #-cffi
  `(make-instance 'library ,@initargs))

Macroexpansion:
(change-class (cffi::get-foreign-library (quote libwinpthread)) (quote library))
Define a macro that eliminates this repetitive pattern:
(defun-compile-time walk-function (map-function reduce-function screamer? partial? nested? form environment) (unless (null (rest (last form))) (error "Improper FUNCTION: ~S" form)) (unless (= (length form) 2) (error "FUNCTION must have one argument: ~S" form)) (cond ((lambda-expression? (second form)) (if (and reduce-function nested?) (funcall reduce-function (funcall map-function form 'function-lambda) (funcall reduce-function (walk-lambda-list map-function reduce-function screamer? partial? nested? (second (second form)) environment) (reduce reduce-function (mapcar #'(lambda (subform) (walk map-function reduce-function screamer? partial? nested? subform environment)) (peal-off-documentation-string-and-declarations (rest (rest (second form))) t))))) (funcall map-function form 'function-lambda))) ((valid-function-name? (second form)) (cond ((symbolp (second form)) (if (or (special-operator-p (second form)) (macro-function (second form) environment)) (error "You can't reference the FUNCTION of a special form or~%~ macro: ~S" form) (funcall map-function form 'function-symbol))) (t (funcall map-function form 'function-setf)))) (t (error "Invalid argument to FUNCTION: ~S" form))))

Issue: 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 walk-function (map-function reduce-function screamer? partial? nested? form environment) (unless (null (rest (last form))) (error "Improper FUNCTION: ~S" form)) (unless (= (length form) 2) (error "FUNCTION must have one argument: ~S" form)) (cond ((lambda-expression? (second form)) (if (and reduce-function nested?) (funcall reduce-function (funcall map-function form (quote function-lambda)) (funcall reduce-function (walk-lambda-list map-function reduce-function screamer? partial? nested? (second (second form)) environment) (reduce reduce-function (mapcar (function (lambda (subform) (walk map-function reduce-function screamer? partial? nested? subform environment))) (peal-off-documentation-string-and-declarations (rest (rest (second form))) t))))) (funcall map-function form (quote function-lambda)))) ((valid-function-name? (second form)) (cond ((symbolp (second form)) (if (or (special-operator-p (second form)) (macro-function (second form) environment)) (error "You can't reference the FUNCTION of a special form or~%~ macro: ~S" form) (funcall map-function form (quote function-symbol)))) (t (funcall map-function form (quote function-setf))))) (t (error "Invalid argument to FUNCTION: ~S" form)))) (eval-when (:compile-toplevel) (compile (quote walk-function))))
Create a Common Lisp macro for the following transformation. Before code:
(collect-max 'some-name)

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

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

Macroexpansion:
(common-lisp:let* ((#:generator-387 (generator 'some-name))
                   #:numbers-381
                   (#:number-383 nil))
  (declare (type generator #:generator-387))
  (tagbody
   #:ll-388
    (setq #:numbers-381 (next-in #:generator-387 (go end)))
    (if (or (null #:number-383) (< #:number-383 #:numbers-381))
        (setq #:number-383 #:numbers-381))
    (go #:ll-388)
   end)
  (if (null #:number-383)
      (setq #:number-383 nil))
  #:number-383)
Define a macro that eliminates this repetitive pattern:
(builder :session (lambda (env) (when (string= (getf env :path-info) "/expire") (setf (getf (getf env :lack.session.options) :expire) t)) '(200 () ("hi"))))

Issue: Macro call that should be transformed by builder

Macro definition:
(defmacro builder (&rest app-or-middlewares)
  (let ((middlewares (butlast app-or-middlewares)))
    `(reduce #'funcall
             (remove-if
              #'null
              (list
               ,@(loop for mw in middlewares
                       when mw
                         collect (convert-to-middleware-form mw))))
             :initial-value (to-app ,(car (last app-or-middlewares)))
             :from-end t)))

Macroexpansion:
(reduce (function funcall) (remove-if (function null) (list (find-middleware :session))) :initial-value (to-app (lambda (env) (when (string= (getf env :path-info) "/expire") (setf (getf (getf env :lack.session.options) :expire) t)) (quote (200 nil ("hi"))))) :from-end t)
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)
  (let ((keys (gensym))
	(key  (gensym))
	(kvc  (gensym))
	(val  (gensym)))
    `(multiple-value-bind (,keys ,val) (op-split (unwrap (list ($exp+ ,@args))))
       (let ((,kvc (kv (car ,keys) (kv ,op ,val))))
	 (dolist (,key (cdr ,keys))
	   (setf ,kvc (kv ,kvc (kv ,key (kv ,op ,val)))))
	 ,kvc))))

Macroexpansion:
(multiple-value-bind (#:g321 #:g324) (op-split (unwrap (list ($exp+ l)))) (let ((#:g323 (kv (car #:g321) (kv op #:g324)))) (dolist (#:g322 (cdr #:g321)) (setf #:g323 (kv #:g323 (kv #:g322 (kv op #:g324))))) #:g323))
Create a Common Lisp macro for the following transformation. Before code:
(some->> 'some-name)

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

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

Macroexpansion:
(let* ((#:g129 'some-name))
  #:g129)
Write a Common Lisp macro to handle this code pattern:
(with-html (:doctype) (:html (:body (:div (:p lorem-ipsum (:span) (:a :href "" :data-instant t "Hello") lorem-ipsum)))))

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

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

Macroexpansion:
(let ((*html* (ensure-html-stream *html*))) (progn (doctype) (with-tag (:html :lang *html-lang*) (with-tag (:body) (with-tag (:div) (with-tag (:p) lorem-ipsum (with-tag (:span)) (with-tag (:a :href "" :data-instant t) "Hello") lorem-ipsum))))))
Generate a defmacro form that transforms code like this:
(undefcategory :debug)

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

Macro definition:
(defmacro undefcategory (category &optional set)
  `(undefcategory-fn ',category ,set))

Macroexpansion:
(undefcategory-fn (quote :debug) nil)
Write a Common Lisp macro to handle this code pattern:
(signal-syntax-error* (1- (lexer-pos lexer)) "Character '~A' may not follow '(?'." next-char)

Problem: 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 (1- (lexer-pos lexer)) :format-control "Character '~A' may not follow '(?'." :format-arguments (list next-char))
Create a Common Lisp macro for the following transformation. Before code:
(-> :g () (put 0) 1)

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

Macro definition:
(defmacro -> (invariant &body args)
  "See flow:atomically"
  `(atomically ,invariant ,@args))

Macroexpansion:
(atomically :g nil (put 0) 1)
You are a Common Lisp macro expert. Given this code pattern:
(-> :p (a) (declare (type fixnum a)) (the fixnum (+ a i)))

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

Macro definition:
(defmacro -> (invariant &body args)
  "See flow:atomically"
  `(atomically ,invariant ,@args))

Macroexpansion:
(atomically :p (a) (declare (type fixnum a)) (the fixnum (+ a i)))
You are a Common Lisp macro expert. Given this code pattern:
(define-interpreter oid:+char+ "char" int 1)

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

Macro definition:
(defmacro define-interpreter (oid name fields &body value)
  "Shorthand for defining binary readers."
  (declare (ignore name)) ;; Names are there just for clarity
  `(set-sql-reader ,oid (binary-reader ,fields ,@value) :binary-p t))

Macroexpansion:
(set-sql-reader cl-postgres-oid:+char+ (binary-reader int 1) :binary-p t)
Create a Common Lisp macro for the following transformation. Before code:
(aand 1 t (values it 2))

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

Macro definition:
(defmacro aand (first &rest rest)
  "Like AND, except binds the first argument to IT (via LET) for the
scope of the rest of the arguments."
  `(anaphoric and ,first ,@rest))

Macroexpansion:
(anaphoric and 1 t (values it 2))
Generate a defmacro form that transforms code like this:
(with-decoder-simple-list-semantics (is (equalp (decode-json-from-string (format nil input "{\"lispPackage\":\"jsonTest\", \"lispClass\":\"frob\"}")) '((:bar . 46) (:xyzzy . t) (:quux . 98) (:prototype . ((:lisp-package . "jsonTest") (:lisp-class . "frob")))))))

Pattern to recognize: Macro call that should be transformed by with-decoder-simple-list-semantics

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

Macroexpansion:
(with-shadowed-custom-vars (set-decoder-simple-list-semantics) (is (equalp (decode-json-from-string (format nil input "{\"lispPackage\":\"jsonTest\", \"lispClass\":\"frob\"}")) (quote ((:bar . 46) (:xyzzy . t) (:quux . 98) (:prototype (:lisp-package . "jsonTest") (:lisp-class . "frob")))))))
You are a Common Lisp macro expert. Given this code pattern:
(f_n
  nil
  nil)

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

Macro definition:
(defmacro F_N ...)

Macroexpansion:
(lambda (&rest _) nil nil)
Write a Common Lisp macro to handle this code pattern:
(with-forced-status (:failed) (false NIL))

Problem: Macro call that should be transformed by with-forced-status

Macro definition:
(defmacro with-forced-status ((status &optional description &rest format-args) &body tests)
  `(eval-in-context
    *context*
    (make-instance 'controlling-result
                   :expression ,status
                   :child-status ,status
                   :body (lambda () ,@tests)
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))

Macroexpansion:
(eval-in-context *context* (make-instance (quote controlling-result) :expression :failed :child-status :failed :body (lambda nil (false nil))))
Generate a defmacro form that transforms code like this:
(with-wcs-math-error-handling ((quot rem) (fround x y)) (check-wcs-math-result) rem)

Pattern to recognize: Macro call that should be transformed by with-wcs-math-error-handling

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

Macroexpansion:
(let* ((#:g257 x) (#:g258 y) (#:g259 (list #:g257 #:g258))) (declare (ignorable #:g258) (type list #:g259) (dynamic-extent #:g259)) (catch (quote return-from-with-wcs-math-error-handling) (multiple-value-bind (quot rem) (call-with-wcs-math-error-handler (quote fround) #:g259) (flet ((check-wcs-math-result (&optional (ret quot) (arg-list #:g259)) (check-wcs-math-result ret arg-list))) (check-wcs-math-result) rem))))
You are a Common Lisp macro expert. Given this code pattern:
(lambda () :key nil)

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

Macro definition:
(defmacro LAMBDA ...)

Macroexpansion:
#'(lambda () :key nil)
Create a Common Lisp macro for the following transformation. Before code:
(gathering nil)

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

Macro definition:
(defmacro GATHERING ...)

Macroexpansion:
(common-lisp:let ()
  (values))
Write a Common Lisp macro to handle this code pattern:
(with-preprocessor-state-slots (state) (when if-section-skip-reason (begin-if-section state '(:skipped :if) nil) (return-from process-preprocessing-directive nil)) (unless (preprocessor-token-exists-p directive-token-list) (raise-no-preprocessor-token-error directive-symbol)) (let ((result (eval-if-expression directive-symbol directive-token-list state))) (begin-if-section state directive-token-list result)))

Problem: Macro call that should be transformed by with-preprocessor-state-slots

Macro definition:
(defmacro with-preprocessor-state-slots ((state) &body body)
  `(with-accessors ((file-pathname pp-state-file-pathname)
                    (token-list pp-state-token-list)
                    (result-list pp-state-result-list)
                    (line-number pp-state-line-number)
                    (tokens-in-line pp-state-tokens-in-line)
                    (macro-alist pp-state-macro-alist)
                    (if-section-stack pp-state-if-section-stack)
                    (if-section-skip-reason pp-state-if-section-skip-reason)
                    (include-stack pp-state-include-stack))
       ,state
     ,@body))

Macroexpansion:
(with-accessors ((file-pathname pp-state-file-pathname) (token-list pp-state-token-list) (result-list pp-state-result-list) (line-number pp-state-line-number) (tokens-in-line pp-state-tokens-in-line) (macro-alist pp-state-macro-alist) (if-section-stack pp-state-if-section-stack) (if-section-skip-reason pp-state-if-section-skip-reason) (include-stack pp-state-include-stack)) state (when if-section-skip-reason (begin-if-section state (quote (:skipped :if)) nil) (return-from process-preprocessing-directive nil)) (unless (preprocessor-token-exists-p directive-token-list) (raise-no-preprocessor-token-error directive-symbol)) (let ((result (eval-if-expression directive-symbol directive-token-list state))) (begin-if-section state directive-token-list result)))
Create a Common Lisp macro for the following transformation. Before code:
(builder (:mount "/admin" (lambda (env) `(200 () ("admin" ,(getf env :path-info))))) *app*)

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

Macro definition:
(defmacro builder (&rest app-or-middlewares)
  (let ((middlewares (butlast app-or-middlewares)))
    `(reduce #'funcall
             (remove-if
              #'null
              (list
               ,@(loop for mw in middlewares
                       when mw
                         collect (convert-to-middleware-form mw))))
             :initial-value (to-app ,(car (last app-or-middlewares)))
             :from-end t)))

Macroexpansion:
(reduce (function funcall) (remove-if (function null) (list (lambda (#:app172) (funcall (find-middleware :mount) #:app172 "/admin" (lambda (env) (sb-int:quasiquote (200 nil ("admin" #S(sb-impl::comma :expr (getf env :path-info) :kind 0))))))))) :initial-value (to-app *app*) :from-end t)
You are a Common Lisp macro expert. Given this code pattern:
(labels* nil)

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

Macro definition:
(defmacro LABELS* ...)

Macroexpansion:
(labels nil)
Define a macro that eliminates this repetitive pattern:
(enable-quasi-quote-syntax nil nil)

Issue: Macro call that should be transformed by ENABLE-QUASI-QUOTE-SYNTAX

Macro definition:
(defmacro ENABLE-QUASI-QUOTE-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-quasi-quote-syntax-in-readtable nil nil :nested-quasi-quote-wrapper
                                       quasi-quote-wrapper :start-character nil
                                       :dispatch-character nil :end-character
                                       nil :unquote-character #\COMMA
                                       :splice-character #\COMMERCIAL_AT
                                       :destructive-splice-character
                                       #\FULL_STOP :dispatched-quasi-quote-name
                                       nil :toplevel-reader-wrapper #'identity
                                       :unquote-readtable-case nil :body-reader
                                       nil :readtable-case nil)
  (values))
You are a Common Lisp macro expert. Given this code pattern:
(define-modf-rewrite fifth (expr) `(car (cddddr ,(second expr))))

Write a macro that addresses: 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 fifth) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (car (cddddr #S(sb-impl::comma :expr (second expr) :kind 0)))))))
Generate a defmacro form that transforms code like this:
(defun/1 tolower (c) (char-downcase (code-char c)))

Pattern to recognize: 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 tolower (c) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (char-downcase (code-char c))) (defparameter tolower (vacietis.c:mkptr& (symbol-function (quote tolower)))))
Write a Common Lisp macro to handle this code pattern:
(define-method-combination% and :operator and :identity-with-one-argument t)

Problem: Macro call that should be transformed by define-method-combination%

Macro definition:
(defmacro define-method-combination% (name &rest args)
  "Define a method-combination for the static-dispatch system only.

   Arguments are of the same form as to CL:DEFINE-METHOD-COMBINATION."

  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf
      (combination-function ',name)
      ,(match args
         ((or nil
              (list* (and (type symbol) (not nil)) _))

          (destructuring-bind (&key (operator name) (identity-with-one-argument nil))
              args

            `(method-combination-function-short ,name ,operator ,identity-with-one-argument)))

         (_
          `(method-combination-function ,name ,@args))))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (combination-function (quote and)) (method-combination-function-short and and t)))