j14i/cl-macros huggingface dataset:
Define a macro that eliminates this repetitive pattern:
(signal-syntax-error* (lexer-pos lexer) "Expected left brace after \\~A." first-char)

Issue: 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 (lexer-pos lexer) :format-control "Expected left brace after \\~A." :format-arguments (list first-char))
Write a Common Lisp macro to handle this code pattern:
(multi-line-mode-p flags)

Problem: Macro call that should be transformed by multi-line-mode-p

Macro definition:
(defmacro multi-line-mode-p (flags)
  "Accessor macro to extract the second flag out of a three-element flag list."
  `(second ,flags))

Macroexpansion:
(second flags)
Create a Common Lisp macro for the following transformation. Before code:
(receive (one two) (values 1 2 3) (list one two))

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

Macro definition:
(defmacro receive (formals expr &body body)
  "Stricter version of `multiple-value-bind'.

Use `receive' when you want to enforce that EXPR should return a
certain number of values, or a minimum number of values.

If FORMALS is a proper list, then EXPR must return exactly as many
values -- no more and no less -- as there are variables in FORMALS.

If FORMALS is an improper list (VARS . REST), then EXPR must return at
least as many values as there are VARS, and any further values are
bound, as a list, to REST.

Lastly, if FORMALS is a symbol, bind that symbol to all the values
returned by EXPR, as if by `multiple-value-list'.

From Scheme (SRFI-8)."
  ;; It's probably not worth stack-allocating the thunk.
  (cond ((null formals)
         `(multiple-value-call
              (lambda ()
                ,@body)
            ,expr))
        ((atom formals)
         ;; This could also be written:
         #+(or) `(let ((,formals (multiple-value-list ,expr)))
                   ,@body)
         ;; But I want it to be possible to declare FORMALS to have
         ;; dynamic extent, and most Lisps support that for &rest
         ;; lists.
         `(multiple-value-call
              (lambda (&rest ,formals)
                ,@body)
            ,expr))
        ((proper-list-p formals)
         (when (intersection formals lambda-list-keywords)
           (error "Lambda list keywords in formals: ~a" formals))
         `(multiple-value-call
              (lambda ,formals
                ,@body)
            ,expr))
        (t (let* ((last (last formals))
                  (vars (append (butlast formals)
                                (list (car last))))
                  (rest (cdr last)))
             (when (intersection (cons rest vars) lambda-list-keywords)
               (error "Lambda list keywords in formals: ~a" formals))
             `(multiple-value-call
                  (lambda (,@vars &rest ,rest)
                    ,@body)
                ,expr)))))

Macroexpansion:
(multiple-value-call (lambda (one two) (list one two)) (values 1 2 3))
Create a Common Lisp macro for the following transformation. Before code:
(with-reader-syntax (describe) (is (string= (with-output-to-string (*standard-output*) (describe 'reader:enable-reader-syntax)) (er "(with-output-to-string (*standard-output*) ?reader:enable-reader-syntax )"))))

What needs to change: Macro call that should be transformed by with-reader-syntax

Macro definition:
(defmacro with-reader-syntax (reader-macro-identifiers &body body)
  "This macro is only made for use by read-and-eval functionality,
and rather directed towards tests than users. So, do not export."
  (let ((identifiers (loop :for identifier :in reader-macro-identifiers
                           :collect `(quote ,identifier))))
    `(let ((*array-function*         'make-t-array-from-initial-contents)
           (*hash-table-function*    'alexandria:plist-hash-table)
           (*get-val-function*       'get-val)
           (*get-val-array-function* 'cl:aref)
           (*set-function*           'cl:remove-duplicates)
           (*alists-are-lists*       nil)
           (*plists-are-lists*       nil)
           (*readtable*             (%enable-reader-syntax *readtable* ,@identifiers)))
       ,@body)))

Macroexpansion:
(let ((*array-function* (quote make-t-array-from-initial-contents)) (*hash-table-function* (quote alexandria:plist-hash-table)) (*get-val-function* (quote get-val)) (*get-val-array-function* (quote aref)) (*set-function* (quote remove-duplicates)) (*alists-are-lists* nil) (*plists-are-lists* nil) (*readtable* (%enable-reader-syntax *readtable* (quote describe)))) (is (string= (with-output-to-string (*standard-output*) (describe (quote enable-reader-syntax))) (er "(with-output-to-string (*standard-output*) ?reader:enable-reader-syntax )"))))
Write a Common Lisp macro to handle this code pattern:
(deferror "42" 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 syntax-error-or-access-violation (database-error) nil) (setf (gethash "42" *error-table*) (quote syntax-error-or-access-violation)))
Create a Common Lisp macro for the following transformation. Before code:
(iter)

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

Macro definition:
(defmacro ITER ...)

Macroexpansion:
(let* ()
  (block nil
    (block nil
      (tagbody (progn) loop-top-nil (progn) (progn) (go loop-top-nil) (progn))
      nil)))
Create a Common Lisp macro for the following transformation. Before code:
(def-neo4j-fun delete-node (node-id) :delete (:uri-spec (format nil "node/~A" node-id)) (:status-handlers (204 (values t body)) (404 (error 'node-not-found-error :uri uri)) (409 (error 'unable-to-delete-node-error :uri uri))))

What needs to change: 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 delete-node (&key node-id) (let ((uri (format nil "node/~A" node-id)) (json (encode-neo4j-json-payload nil :string))) (make-neo4j-request :delete uri json (list (list 204 (lambda (body uri json) (values t body))) (list 404 (lambda (body uri json) (error (quote node-not-found-error) :uri uri))) (list 409 (lambda (body uri json) (error (quote unable-to-delete-node-error) :uri uri))))))))
Write a Common Lisp macro to handle this code pattern:
(define-modf-function subseq 1 (new-val seq start &optional (end (length seq))) (concatenate (type-of seq) (subseq seq 0 start) (subseq new-val 0 (min (length new-val) (- end start))) (subseq seq (+ start (min (length new-val) (- end start))))))

Problem: 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 subseq) *modf-nth-arg*) 1)) (defun |BUILDER:COMMON-LISP:SUBSEQ| (new-val seq start &optional (end (length seq))) (concatenate (type-of seq) (subseq seq 0 start) (subseq new-val 0 (min (length new-val) (- end start))) (subseq seq (+ start (min (length new-val) (- end start)))))))
You are a Common Lisp macro expert. Given this code pattern:
(define-path-instruction-pair vertical-to "V" (y))

Write a macro that addresses: Macro call that should be transformed by define-path-instruction-pair

Macro definition:
(defmacro define-path-instruction-pair (name instruction (&rest args))
  (let ((draw-relative (intern (concatenate 'string (string name) "-R"))))
    `(progn
       (defun ,name (,@args)
         (format-instruction ,instruction ,@args))
       (defun ,draw-relative (,@args)
         (format-instruction ,(string-downcase instruction) ,@args)))))

Macroexpansion:
(progn (defun vertical-to (y) (format-instruction "V" y)) (defun vertical-to-r (y) (format-instruction "v" y)))
You are a Common Lisp macro expert. Given this code pattern:
(define _IOFBF 1)

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

Macro definition:
(defmacro define (name value &rest docstring)
  "Like a #define but also visible to Lisp code."
  `(progn
     (eval-when (:compile-toplevel :load-toplevel :execute)
       (defvar ,(pp-defines *package*) (make-hash-table))
       (setf (gethash ',name ,(pp-defines *package*)) ,(prin1-to-string value)))
     (defparameter ,name ,value ,@docstring)))

Macroexpansion:
(progn (eval-when (:compile-toplevel :load-toplevel :execute) (defvar *preprocessor-defines* (make-hash-table)) (setf (gethash (quote _iofbf) *preprocessor-defines*) #A((1) base-char . "1"))) (defparameter _iofbf 1))
You are a Common Lisp macro expert. Given this code pattern:
(binding-forms (get 'bind :binding-forms))

Write a macro that addresses: 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:
(binding-forms (get (quote bind) :binding-forms))
Create a Common Lisp macro for the following transformation. Before code:
(aif it it)

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

Macro definition:
(defmacro aif (test then &optional else)
  "Like IF, except binds the result of the test to IT (via LET) for
the scope of the then and else expressions."  
  `(anaphoric if ,test ,then ,else))

Macroexpansion:
(anaphoric if it it nil)
Create a Common Lisp macro for the following transformation. Before code:
(dletf* nil
  (progn))

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

Macro definition:
(defmacro DLETF* ...)

Macroexpansion:
(progn (progn))
Define a macro that eliminates this repetitive pattern:
(*> +skip-all-space+ +skip-comments+)

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 (#:*>-offset251) (multiple-value-bind (#:*>-res252 #:*>-next253) (funcall +skip-all-space+ #:*>-offset251) (if (ok? #:*>-res252) (funcall +skip-comments+ #:*>-next253) (fail #:*>-next253))))
You are a Common Lisp macro expert. Given this code pattern:
(ψ nil :key nil)

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

Macro definition:
(defmacro Ψ ...)

Macroexpansion:
(mapcar (λ :key nil) nil)
Define a macro that eliminates this repetitive pattern:
(defun nil (progn))

Issue: Macro call that should be transformed by DEFUN

Macro definition:
(defmacro DEFUN ...)

Macroexpansion:
(progn
 (eval-when (:compile-toplevel) (sb-c:%compiler-defun 'nil t nil nil))
 (sb-impl::%defun 'nil
                  (sb-int:named-lambda nil
                      (progn)
                    (block nil))))
Create a Common Lisp macro for the following transformation. Before code:
(lret ((out (make-array shape :element-type element-type))) (replace* (%flatten out) (%flatten array)))

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

Macro definition:
(defmacro lret ((&rest bindings) &body body)
  "Return the initial value of the last binding in BINDINGS. The idea
is to create something, initialize it, and then return it.

    (lret ((x 1)
           (y (make-array 1)))
      (setf (aref y 0) x))
    => #(1)

Note that the value returned is the value initially bound. Subsequent
assignments are ignored.

    (lret ((x 1))
      (setf x 2))
    => 1

Furthermore, on Lisps that support it, the variable may be made
read-only, making assignment a compiler-time error.

`lret' may seem trivial, but it fufills the highest purpose a macro
can: it eliminates a whole class of bugs (initializing an object, but
forgetting to return it).

Cf. `aprog1' in Anaphora."
  `(lret-aux let ,bindings
     ,@body))

Macroexpansion:
(lret-aux let ((out (make-array shape :element-type element-type))) (replace* (%flatten out) (%flatten array)))
Write a Common Lisp macro to handle this code pattern:
(defclass/a dbd-null (cl-dbi:dbi-driver) ())

Problem: Macro call that should be transformed by defclass/a

Macro definition:
(defmacro defclass/a (name superclasses slots &rest class-options)
  `(progn
     (defclass ,name ,superclasses ,slots ,@class-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 (defclass dbd-null (dbi.driver:dbi-driver) nil) (deftype <dbd-null> nil (quote dbd-null)) (setf (find-class (quote <dbd-null>)) (find-class (quote dbd-null))))
Generate a defmacro form that transforms code like this:
(letrec* (x) x)

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

Macro definition:
(defmacro letrec ((&rest bindings) &body body)
  "Recursive LET.
The idea is that functions created in BINDINGS can close over one
another, and themselves.

Note that `letrec' only binds variables: it can define recursive
functions, but can't bind them as functions. (But see `fbindrec'.)"
  `(letrec-with psetq ,bindings
     ,@body))

Macroexpansion:
(letrec-with setq (x) x)
You are a Common Lisp macro expert. Given this code pattern:
(min-of nil
  nil)

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

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

Macroexpansion:
(lc (nil nil) minimize)
You are a Common Lisp macro expert. Given this code pattern:
(define-find-c-readtable-name-methods c-reader-level-0 0)

Write a macro that addresses: Macro call that should be transformed by define-find-c-readtable-name-methods

Macro definition:
(defmacro define-find-c-readtable-name-methods (base-readtable-name level)
  (check-type base-readtable-name symbol)
  (check-type level integer)
  (loop with case-modes = '(nil :upcase :downcase :preserve :invert)
        for mode in case-modes
        as name = (format-symbol :with-c-syntax.core "~A~@[-~A~]"
                                 base-readtable-name mode)
        collect `(defmethod find-c-readtable-name
                     ((level (eql ,level)) (readtable-case (eql ,mode)))
                   ',name)
          into bodies
        finally
           (return `(progn ,@bodies))))

Macroexpansion:
(progn (defmethod find-c-readtable-name ((level (eql 0)) (readtable-case (eql nil))) (quote c-reader-level-0)) (defmethod find-c-readtable-name ((level (eql 0)) (readtable-case (eql :upcase))) (quote c-reader-level-0-upcase)) (defmethod find-c-readtable-name ((level (eql 0)) (readtable-case (eql :downcase))) (quote c-reader-level-0-downcase)) (defmethod find-c-readtable-name ((level (eql 0)) (readtable-case (eql :preserve))) (quote c-reader-level-0-preserve)) (defmethod find-c-readtable-name ((level (eql 0)) (readtable-case (eql :invert))) (quote c-reader-level-0-invert)))
Create a Common Lisp macro for the following transformation. Before code:
(def-unary-op vacietis.c:~ lognot)

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

Macro definition:
(defmacro def-unary-op (c lisp)
  (let ((x (gensym)))
   `(defmacro ,c (,x)
      `(,',lisp ,,x))))

Macroexpansion:
(defmacro vacietis.c:~ (#:g225) (sb-int:quasiquote (#S(sb-impl::comma :expr (quote lognot) :kind 0) #S(sb-impl::comma :expr #:g225 :kind 0))))
Generate a defmacro form that transforms code like this:
(product-of nil
  :key
  nil)

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

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

Macroexpansion:
(lc (nil :key nil) multiply)
Define a macro that eliminates this repetitive pattern:
(assoc-cdr "oauth_token" parameters #'equal)

Issue: Macro call that should be transformed by assoc-cdr

Macro definition:
(defmacro assoc-cdr (key alist &optional (test '#'eql))
  `(cdr (assoc ,key ,alist :test ,test)))

Macroexpansion:
(cdr (assoc "oauth_token" parameters :test (function equal)))
Define a macro that eliminates this repetitive pattern:
(defun/1 modf (x ptr) (multiple-value-bind (whole part) (fround x) (setf (deref* ptr) whole) part))

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

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

Macroexpansion:
(progn (defun modf (x ptr) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (multiple-value-bind (whole part) (fround x) (setf (deref* ptr) whole) part)) (defparameter modf (vacietis.c:mkptr& (symbol-function (quote modf)))))
Generate a defmacro form that transforms code like this:
(defmessage nil (progn))

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

Macro definition:
(defmacro DEFMESSAGE ...)

Macroexpansion:
(progn
 (eval-when (:compile-toplevel) (proclaim `(ftype function ,'nil)))
 (aprog1 (ensure-message 'nil :lambda-list '(progn))))
Define a macro that eliminates this repetitive pattern:
(defun/1 va_copy (dest src) (setf (deref* dest) (deref* src)))

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

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

Macroexpansion:
(progn (defun va_copy (dest src) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (setf (deref* dest) (deref* src))) (defparameter va_copy (vacietis.c:mkptr& (symbol-function (quote va_copy)))))
You are a Common Lisp macro expert. Given this code pattern:
(define-left-arrow-accessors nil)

Write a macro that addresses: Macro call that should be transformed by DEFINE-LEFT-ARROW-ACCESSORS

Macro definition:
(defmacro DEFINE-LEFT-ARROW-ACCESSORS ...)

Macroexpansion:
(progn (declaim (inline)) 'nil)
You are a Common Lisp macro expert. Given this code pattern:
(when (first in-decl) (setf (first in-decl-item) t))

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 (first in-decl) (setf (first in-decl-item) t))
Create a Common Lisp macro for the following transformation. Before code:
(lambda-ignoring-_ (dspecs _t) (finalize-decl-specs dspecs) `(,dspecs nil))

What needs to change: Macro call that should be transformed by lambda-ignoring-_

Macro definition:
(defmacro lambda-ignoring-_ (lambda-list &body body)
  "Works like `cl:lambda' macro except automatically `declare's
 `ignore' for parameters beginning with '_' character."
  (let ((ignored-parameters
          (collect-_-symbol-in-lambda-list lambda-list)))
    (unless ignored-parameters
      (warn "No ignored parameters in: ~A" lambda-list))
    (multiple-value-bind (body decls doc)
        (parse-body body :documentation t)
      `(lambda ,lambda-list
         ,@ (if doc `(,doc))
         (declare (ignore ,@ignored-parameters))
         ,@decls
         ,@body))))

Macroexpansion:
(lambda (dspecs _t) (declare (ignore _t)) (finalize-decl-specs dspecs) (sb-int:quasiquote (#S(sb-impl::comma :expr dspecs :kind 0) nil)))
Create a Common Lisp macro for the following transformation. Before code:
(is-values (values 1 2 nil 3) '(1 2 nil 3))

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

Macro definition:
(defmacro is (got expected &rest args)
  (with-gensyms (duration result new-args desc)
    (once-only (expected)
      `(let* ((,new-args (list ,@args))
              (,desc (parse-description-and-test ,new-args)))
         (with-catching-errors (:description ,desc :expected ,expected)
           (with-duration ((,duration ,result) ,got)
             (test ,result ,expected ,new-args
                   :duration ,duration)))))))

Macroexpansion:
(is (multiple-value-list (values 1 2 nil 3)) (quote (1 2 nil 3)))