j14i/cl-macros huggingface dataset:
Generate a defmacro form that transforms code like this:
(make-name-transformer name "-ZORK")

Pattern to recognize: Macro call that should be transformed by make-name-transformer

Macro definition:
(defmacro make-name-transformer (&rest elements)
  "Return an accessor name transformer.
The unquoted `name' symbol argument is substituted for the slot name.
Class option examples:

  :accessor-name-transformer (make-name-transformer \"FOO-\" name \"-BAR\")

Use the slot name directly:

  :accessor-name-transformer (make-name-transformer name)"
  `(lambda (name definition)
    (declare (ignorable definition))
    (concatenate-symbol ,@(mapcar (lambda (el)
                                    (if (and (symbolp el)
                                             (string= (symbol-name el) "NAME"))
                                        'name
                                        el))
                                  elements))))

Macroexpansion:
(lambda (name definition) (declare (ignorable definition)) (concatenate-symbol name "-ZORK"))
Define a macro that eliminates this repetitive pattern:
(check-cursor-attached cluffer:beginning-of-line-p (cursor))

Issue: 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:beginning-of-line-p :before ((cursor cluffer:cursor)) (declare (ignore)) (unless (cluffer:cursor-attached-p cursor) (error (quote cluffer:cursor-detached))))
You are a Common Lisp macro expert. Given this code pattern:
(letrec-syntax common-lisp:nil (common-lisp:progn))

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

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

Macroexpansion:
(common-lisp:macrolet ()
  (common-lisp:progn))
You are a Common Lisp macro expert. Given this code pattern:
(augment init-code `((setq ,extra-save-var ,(save-info-iv-ref s-i))))

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

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

Macroexpansion:
(setf init-code (nconc init-code (sb-int:quasiquote ((setq #S(sb-impl::comma :expr extra-save-var :kind 0) #S(sb-impl::comma :expr (save-info-iv-ref s-i) :kind 0))))))
Generate a defmacro form that transforms code like this:
(with-quote-char (map nil (lambda (ex) (format out "~&~A;~%~A" (sxql:yield ex) statement-separator)) expressions))

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

Macro definition:
(defmacro with-quote-char (&body body)
  `(let ((sxql:*quote-character* (or sxql:*quote-character*
                                     (connection-quote-character *connection*))))
     ,@body))

Macroexpansion:
(let ((sxql/sql-type:*quote-character* (or sxql/sql-type:*quote-character* (connection-quote-character *connection*)))) (map nil (lambda (ex) (format out "~&~A;~%~A" (sxql/sql-type:yield ex) statement-separator)) expressions))
You are a Common Lisp macro expert. Given this code pattern:
(count-of nil
  :key
  nil)

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

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

Macroexpansion:
(lc (nil :key nil) count)
Create a Common Lisp macro for the following transformation. Before code:
(define-custom-var (:array-scope *array-scope-variables*) '(*internal-decoder*) "A list of symbols naming dynamic variables which should be re-bound in the scope of every JSON Array.")

What needs to change: 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 (*array-scope-variables* . :array-scope)) *custom-vars* :test (function equal)) (defvar *array-scope-variables* (quote (*internal-decoder*)) "A list of symbols naming dynamic variables which should be re-bound in the scope of every JSON Array.")))
You are a Common Lisp macro expert. Given this code pattern:
(with-collectors nil
  nil)

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

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

Macroexpansion:
(progn nil)
Define a macro that eliminates this repetitive pattern:
(lambda-match0 ((cons key pattern) `(assoc ,key ,pattern)))

Issue: Macro call that should be transformed by lambda-match0

Macro definition:
(defmacro lambda-match0 (&body clauses)
  (alexandria:with-gensyms (arg)
    `(lambda (,arg)
       (match0 ,arg
         ,@clauses))))

Macroexpansion:
(lambda (#:arg165) (match0 #:arg165 ((cons key pattern) (sb-int:quasiquote (assoc #S(sb-impl::comma :expr key :kind 0) #S(sb-impl::comma :expr pattern :kind 0))))))
Create a Common Lisp macro for the following transformation. Before code:
(defmacro-driver 'some-name)

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

Macro definition:
(defmacro DEFMACRO-DRIVER ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defmacro clause-quote-2 (&key ((:quote some-name)) generate))
  (iterate::install-clause-info '(quote) '(quote) 'clause-quote-2 nil t)
  ''some-name)
Create a Common Lisp macro for the following transformation. Before code:
(check-cursor-attached cluffer:items (cursor &key start end))

What needs to change: 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:items :before ((cursor cluffer:cursor) &key start end) (declare (ignore end start)) (unless (cluffer:cursor-attached-p cursor) (error (quote cluffer:cursor-detached))))
You are a Common Lisp macro expert. Given this code pattern:
(none-of nil
  :key
  nil)

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

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

Macroexpansion:
(lc (nil :key nil) never)
Define a macro that eliminates this repetitive pattern:
(collect-max nil :key nil)

Issue: Macro call that should be transformed by COLLECT-MAX

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

Macroexpansion:
(common-lisp:let* ((#:generator-379 (generator :key))
                   #:items-369
                   (#:generator-377 (generator nil))
                   #:numbers-368
                   (#:number-371 nil)
                   #:result-372)
  (declare (type generator #:generator-379)
           (type generator #:generator-377)
           (type (null-or t) #:result-372))
  (tagbody
   #:ll-380
    (setq #:items-369 (next-in #:generator-379 (go end)))
    (setq #:numbers-368 (next-in #:generator-377 (go end)))
    (if (or (null #:number-371) (< #:number-371 #:numbers-368))
        (setq #:number-371 #:numbers-368
              #:result-372 #:items-369))
    (go #:ll-380)
   end)
  (if (null #:number-371)
      (setq #:result-372 nil))
  #:result-372)
Create a Common Lisp macro for the following transformation. Before code:
(define-shell-component roy :input-type "roy" :output-type "js" :shell-command ("roy" "-r"))

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

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

Macroexpansion:
(define-component roy :input-type "roy" :output-type "js" :compile-function (lambda (input-pathname output-pathname) (inferior-shell:run (list "roy" "-r" input-pathname output-pathname) :show t)))
Write a Common Lisp macro to handle this code pattern:
(define-modf-rewrite cddr (expr) `(cdr (cdr ,(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 cddr) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (cdr (cdr #S(sb-impl::comma :expr (second expr) :kind 0)))))))
Create a Common Lisp macro for the following transformation. Before code:
(define-modf-rewrite cdaaar (expr) `(cdr (caaar ,(second expr))))

What needs to change: 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 cdaaar) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (cdr (caaar #S(sb-impl::comma :expr (second expr) :kind 0)))))))
You are a Common Lisp macro expert. Given this code pattern:
(when ret-body (setf body (rest ret-body)) (setf type (first ret-body)))

Write a macro that addresses: 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 ret-body (progn (setf body (rest ret-body)) (setf type (first ret-body))))
Create a Common Lisp macro for the following transformation. Before code:
(defun/1 getc (fd) (fgetc fd))

What needs to change: 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 getc (fd) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (fgetc fd)) (defparameter getc (vacietis.c:mkptr& (symbol-function (quote getc)))))
Write a Common Lisp macro to handle this code pattern:
(define-error unable-to-resolve-func-type () (func-name args) "Unable to resolve the result type of function '~a' when called~%with the argument types:~%~a~%" func-name (mapcar #'type->type-spec (mapcar #'primary-type args)))

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 unable-to-resolve-func-type (:error-type varjo-error :prefix "Varjo") (func-name args) "Unable to resolve the result type of function '~a' when called~%with the argument types:~%~a~%" func-name (mapcar (function type->type-spec) (mapcar (function primary-type) args)))
Write a Common Lisp macro to handle this code pattern:
(def-dynenv-macro nil
    (progn))

Problem: Macro call that should be transformed by DEF-DYNENV-MACRO

Macro definition:
(defmacro DEF-DYNENV-MACRO ...)

Macroexpansion:
(defmacro nil (progn &environment #:env175) (with-dynenv #:env175))
Write a Common Lisp macro to handle this code pattern:
(define-shell-component sass-strict :input-type "sass" :output-type "css" :shell-command "sass")

Problem: Macro call that should be transformed by define-shell-component

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

Macroexpansion:
(define-component sass-strict :input-type "sass" :output-type "css" :compile-function (lambda (input-pathname output-pathname) (inferior-shell:run (list "sass" input-pathname output-pathname) :show t)))
Generate a defmacro form that transforms code like this:
(do+ (accumulating-to foo) (stop-when (> (length foo) 10)) (returning foo) (do+ (for x (in '(1 2 3))) (do+ (for y (in '(a b))) (collect (list x y) :into foo))))

Pattern to recognize: Macro call that should be transformed by do+

Macro definition:
(defmacro do+ (&body body)
  "High-level, extensible iteration construct. Refer to the manual for syntax and semantics."
  `(do+/internal nil ,@body))

Macroexpansion:
(do+/internal nil (accumulating-to foo) (stop-when (> (length foo) 10)) (returning foo) (do+ (for x (in (quote (1 2 3)))) (do+ (for y (in (quote (a b)))) (collect (list x y) :into foo))))
Write a Common Lisp macro to handle this code pattern:
(disable-quasiquote-2.0)

Problem: Macro call that should be transformed by DISABLE-QUASIQUOTE-2.0

Macro definition:
(defmacro DISABLE-QUASIQUOTE-2.0 ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (%disable-quasiquote-2.0))
Generate a defmacro form that transforms code like this:
(ematch0 args (nil nil) ((list* '&key rest) (list* '&key (process-keyword-args rest))) ((list* '&rest rest) (list* '&rest (process-rest-args rest))) ((list* '&aux rest) args) ((list* (list name) rest) (list* (list name ''_) (process-optional-args rest))) ((list* (list name default) rest) (list* (list name default) (process-optional-args rest))) ((list* (list name default pred) rest) (list* (list name default pred) (process-optional-args rest))) ((list* name rest) (list* (list name ''_) (process-optional-args rest))))

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

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

Macroexpansion:
(match0 args (nil nil) ((list* (quote &key) rest) (list* (quote &key) (process-keyword-args rest))) ((list* (quote &rest) rest) (list* (quote &rest) (process-rest-args rest))) ((list* (quote &aux) rest) args) ((list* (list name) rest) (list* (list name (quote (quote _))) (process-optional-args rest))) ((list* (list name default) rest) (list* (list name default) (process-optional-args rest))) ((list* (list name default pred) rest) (list* (list name default pred) (process-optional-args rest))) ((list* name rest) (list* (list name (quote (quote _))) (process-optional-args rest))) (_ (error "level0 match error!")))
Define a macro that eliminates this repetitive pattern:
(slet 42 (alet 43 (slet it it)))

Issue: Macro call that should be transformed by slet

Macro definition:
(defmacro slet (form &body body)
  "Binds the FORM to IT (via SYMBOL-MACROLET) in the scope of the BODY. IT can
be set with SETF."
  `(symbolic ignore-first ,form (progn ,@body)))

Macroexpansion:
(symbolic ignore-first 42 (progn (alet 43 (slet it it))))
Write a Common Lisp macro to handle this code pattern:
(define-alias-binding sum summing)

Problem: Macro call that should be transformed by define-alias-binding

Macro definition:
(defmacro define-alias-binding (name referenced-binding-name)
  `(progn (setf (binding ',name) ',referenced-binding-name)
          ',name))

Macroexpansion:
(progn (setf (binding (quote sum)) (quote summing)) (quote sum))
Write a Common Lisp macro to handle this code pattern:
(define-error flow-ids-mandatory (:error-type varjo-critical-error) (for primary-type) "~a must be given flow id/s when created: type - ~s" for primary-type)

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 flow-ids-mandatory (:error-type varjo-critical-error :prefix "Varjo") (for primary-type) "~a must be given flow id/s when created: type - ~s" for primary-type)
Create a Common Lisp macro for the following transformation. Before code:
(defun-compile-time magic-continuation-argument (continuation) (if (or (eq (first (second (second continuation))) '&optional) (eq (first (second (second continuation))) '&rest)) (second (second (second continuation))) (first (second (second continuation)))))

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 magic-continuation-argument (continuation) (if (or (eq (first (second (second continuation))) (quote &optional)) (eq (first (second (second continuation))) (quote &rest))) (second (second (second continuation))) (first (second (second continuation))))) (eval-when (:compile-toplevel) (compile (quote magic-continuation-argument))))
Define a macro that eliminates this repetitive pattern:
(product-of 'some-name)

Issue: Macro call that should be transformed by PRODUCT-OF

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

Macroexpansion:
(lc ('some-name) multiply)
You are a Common Lisp macro expert. Given this code pattern:
(peek-char*)

Write a macro that addresses: Macro call that should be transformed by peek-char*

Macro definition:
(defmacro peek-char* ()
  "Convenience macro because we always peek at the same string with
the same arguments."
  `(peek-char nil *stream* t nil t))

Macroexpansion:
(peek-char nil *stream* t nil t)
Write a Common Lisp macro to handle this code pattern:
(do+ (for s (symbols-in :doplus-tests :internal)) (for l (maximizing (length (symbol-name s)) :saving s :in symbol-with-longest-name)) (returning symbol-with-longest-name))

Problem: Macro call that should be transformed by do+

Macro definition:
(defmacro do+ (&body body)
  "High-level, extensible iteration construct. Refer to the manual for syntax and semantics."
  `(do+/internal nil ,@body))

Macroexpansion:
(do+/internal nil (for s (symbols-in :doplus-tests :internal)) (for l (maximizing (length (symbol-name s)) :saving s :in symbol-with-longest-name)) (returning symbol-with-longest-name))
You are a Common Lisp macro expert. Given this code pattern:
(ematch0 pattern ((list 'guard1 sym test) (pushnew (first (ensure-list sym)) syms)) ((list* 'guard1 sym test more-patterns) (pushnew (first (ensure-list sym)) syms) (analyze-more-patterns more-patterns)) ((list* 'or1 or-subpatterns) (map nil #'analyze-pattern or-subpatterns)))

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

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

Macroexpansion:
(match0 pattern ((list (quote guard1) sym test) (pushnew (first (ensure-list sym)) syms)) ((list* (quote guard1) sym test more-patterns) (pushnew (first (ensure-list sym)) syms) (analyze-more-patterns more-patterns)) ((list* (quote or1) or-subpatterns) (map nil (function analyze-pattern) or-subpatterns)) (_ (error "level0 match error!")))
Define a macro that eliminates this repetitive pattern:
(drelet nil)

Issue: Macro call that should be transformed by DRELET

Macro definition:
(defmacro DRELET ...)

Macroexpansion:
(dynamic-relet nil)
Generate a defmacro form that transforms code like this:
(define-condition/a dbi-error (simple-error) () (:documentation "Base class of all other error exceptions. Use this to catch all DBI errors."))

Pattern to recognize: Macro call that should be transformed by define-condition/a

Macro definition:
(defmacro define-condition/a (name parent-types slots &body options)
  `(progn
     (define-condition ,name ,parent-types ,slots ,@options)
     (deftype ,(intern (format nil "<~A>" (symbol-name name))) () ',name)
     (setf (find-class ',(intern (format nil "<~A>" (symbol-name name))))
           (find-class ',name))))

Macroexpansion:
(progn (define-condition dbi-error (simple-error) nil (:documentation "Base class of all other error exceptions. Use this to catch all DBI errors.")) (deftype <dbi-error> nil (quote dbi-error)) (setf (find-class (quote <dbi-error>)) (find-class (quote dbi-error))))
You are a Common Lisp macro expert. Given this code pattern:
(define-cruft %readtable-name (readtable) "Return the name associated with READTABLE." #+ :common-lisp (values (gethash readtable *readtable-names*)))

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

Macro definition:
(defmacro define-cruft (name lambda-list &body (docstring . alternatives))
  (assert (typep docstring 'string) (docstring) "Docstring missing!")
  (assert (not (null alternatives)))
  `(progn
     (declaim (inline ,name))
     (defun ,name ,lambda-list ,docstring ,(first alternatives))))

Macroexpansion:
(progn (declaim (inline %readtable-name)) (defun %readtable-name (readtable) "Return the name associated with READTABLE." (values (gethash readtable *readtable-names*))))