j14i/cl-macros huggingface dataset:
Write a Common Lisp macro to handle this code pattern:
(*> (char #\\) (alt (char #\u) (char #\U)) (count 4 #'hex))

Problem: 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 (#:*>-offset192) (multiple-value-bind (#:*>-res195 #:*>-next196) (multiple-value-bind (#:*>-res193 #:*>-next194) (funcall (char #\REVERSE_SOLIDUS) #:*>-offset192) (if (ok? #:*>-res193) (funcall (alt (char #\LATIN_SMALL_LETTER_U) (char #\LATIN_CAPITAL_LETTER_U)) #:*>-next194) (fail #:*>-next194))) (if (ok? #:*>-res195) (funcall (count 4 (function hex)) #:*>-next196) (fail #:*>-next196))))
Create a Common Lisp macro for the following transformation. Before code:
(who-ps-html)

What needs to change: Macro call that should be transformed by WHO-PS-HTML

Macro definition:
(defmacro WHO-PS-HTML ...)

Macroexpansion:
(stringify)
You are a Common Lisp macro expert. Given this code pattern:
(enable-readtime-wrapper-syntax nil)

Write a macro that addresses: Macro call that should be transformed by ENABLE-READTIME-WRAPPER-SYNTAX

Macro definition:
(defmacro ENABLE-READTIME-WRAPPER-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-readtime-wrapper-syntax-in-readtable nil #\RIGHT_CURLY_BRACKET)
  (values))
Generate a defmacro form that transforms code like this:
(cond->>)

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

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

Macroexpansion:
nil
You are a Common Lisp macro expert. Given this code pattern:
(define SEEK_SET 0)

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 seek_set) *preprocessor-defines*) #A((1) base-char . "0"))) (defparameter seek_set 0))
Write a Common Lisp macro to handle this code pattern:
(macroexpand-convention (form) (if (consp form) (expand-incompleted-declamation-using-head (first form) decl-specifier form) form))

Problem: Macro call that should be transformed by macroexpand-convention

Macro definition:
(defmacro macroexpand-convention ((original-form) &body body)
  "Executes BODY as like `progn' and return the result as the first
value.  As the second value, returns a boolean whether the result is
not same with ORIGINAL-FORM or not.
This macro is designed to follow the `macroexpand' convention."
  `(multiple-value-bind (result expanded-p)
       (progn ,@body)
     (values result
             (or expanded-p
                 (not (eq result ,original-form))))))

Macroexpansion:
(multiple-value-bind (result expanded-p) (progn (if (consp form) (expand-incompleted-declamation-using-head (first form) decl-specifier form) form)) (values result (or expanded-p (not (eq result form)))))
Write a Common Lisp macro to handle this code pattern:
(log-message <category> <desctiption> <arguments...>)

Problem: Macro call that should be transformed by log-message

Macro definition:
(defmacro log-message (category description &rest arguments)
  `(log-manager-message (log-manager) ,category ,description ,@arguments))

Macroexpansion:
(log-manager-message (log-manager) <category> <desctiption> <arguments...>)
Create a Common Lisp macro for the following transformation. Before code:
(aetypecase 1.0 (symbol :oops))

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

Macro definition:
(defmacro aetypecase (keyform &body cases)
  "Like ETYPECASE, except binds the result of the keyform to IT (via LET) for
the scope of the cases."
  `(anaphoric etypecase ,keyform ,@cases))

Macroexpansion:
(anaphoric etypecase 1.0 (symbol :oops))
Generate a defmacro form that transforms code like this:
(with-decoder-simple-clos-semantics (setf x (decode-json-from-string "{\"x\":1}")) (is (equal (symbol-package (first-bound-slot-name x)) (find-package :cl-user))))

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

Macro definition:
(defmacro with-decoder-simple-clos-semantics (&body body)
  "Execute BODY in a dynamic environement where the decoder semantics
is such as set by SET-DECODER-SIMPLE-CLOS-SEMANTICS."
  `(with-shadowed-custom-vars
     (set-decoder-simple-clos-semantics)
     ,@body))

Macroexpansion:
(with-shadowed-custom-vars (set-decoder-simple-clos-semantics) (setf x (decode-json-from-string "{\"x\":1}")) (is (equal (symbol-package (first-bound-slot-name x)) (find-package :cl-user))))
Generate a defmacro form that transforms code like this:
(ltbdd-with-new-hash nil
  :key
  nil)

Pattern to recognize: Macro call that should be transformed by LTBDD-WITH-NEW-HASH

Macro definition:
(defmacro LTBDD-WITH-NEW-HASH ...)

Macroexpansion:
(bdd-call-with-new-hash (lambda () :key nil) :bdd-node-type
                        '(or lisp-type-bdd-node bdd-leaf))
Write a Common Lisp macro to handle this code pattern:
(defsynonym :multiplying :mult)

Problem: 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 :multiplying) (quote synonym)) (quote :mult)))
Define a macro that eliminates this repetitive pattern:
(define-hook (:build source-checksum) () (when *source-checksum* (setf *source-checksum* (source-checksum))) (when *build-time* (setf *build-time* (get-universal-time))))

Issue: Macro call that should be transformed by define-hook

Macro definition:
(defmacro define-hook ((type name &optional (priority 0)) args &body body)
  (ecase type (:pre-load) (:load) (:build) (:deploy) (:boot) (:quit))
  (check-type name symbol)
  `(let ((,name (or (hook ,type ',name)
                    (make-instance 'hook :name ',name :type ,type))))
     (setf (hook-priority ,name) ,priority)
     (setf (hook-function ,name) (flet ((,name (&key ,@args &allow-other-keys)
                                          ,@body))
                                   #',name))
     (setf (hook ,type ',name) ,name)
     (setf (docstring ,name) ,(if (stringp (car body)) (car body)))
     ',name))

Macroexpansion:
(let ((source-checksum (or (hook :build (quote source-checksum)) (make-instance (quote hook) :name (quote source-checksum) :type :build)))) (setf (hook-priority source-checksum) 0) (setf (hook-function source-checksum) (flet ((source-checksum (&key &allow-other-keys) (when *source-checksum* (setf *source-checksum* (source-checksum))) (when *build-time* (setf *build-time* (get-universal-time))))) (function source-checksum))) (setf (hook :build (quote source-checksum)) source-checksum) (setf (docstring source-checksum) nil) (quote source-checksum))
You are a Common Lisp macro expert. Given this code pattern:
(bdd-typecase nil)

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

Macro definition:
(defmacro BDD-TYPECASE ...)

Macroexpansion:
((lambda (#:obj131)
   (declare (ignorable #:obj131))
   (block #:block140 (tagbody)))
 nil)
Create a Common Lisp macro for the following transformation. Before code:
(defsynonym summing :sum)

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 summing) (quote synonym)) (quote :sum)))
Write a Common Lisp macro to handle this code pattern:
(define-direct-binding lines-of (var pathname/stream) (let ((arg (gensym "ARGUMENT")) (stream (gensym "STREAM")) (line (gensym "LINE"))) (values `(with-interleaving (let* ((,var NIL) (,arg ,pathname/stream) (,stream (etypecase ,arg ((or string pathname) (open ,arg)) (stream ,arg))))) (unwind-protect* (close ,stream))) `(let ((,line (read-line ,stream NIL NIL))) (if ,line (setf ,var ,line) (end-for))))))

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

Macro definition:
(defmacro define-direct-binding (name args &body body)
  (let ((env (or (lambda-fiddle:environment-lambda-var args) (gensym "ENVIRONMENT"))))
    `(progn (setf (binding ',name)
                  (lambda ,(lambda-fiddle:remove-environment-part args)
                    (let ((,env *environment*))
                      (declare (ignorable ,env))
                      ,@body)))
            ',name)))

Macroexpansion:
(progn (setf (binding (quote lines-of)) (lambda (var pathname/stream) (let ((#:environment128 *environment*)) (declare (ignorable #:environment128)) (let ((arg (gensym "ARGUMENT")) (stream (gensym "STREAM")) (line (gensym "LINE"))) (values (sb-int:quasiquote (with-interleaving (let* ((#S(sb-impl::comma :expr var :kind 0) nil) (#S(sb-impl::comma :expr arg :kind 0) #S(sb-impl::comma :expr pathname/stream :kind 0)) (#S(sb-impl::comma :expr stream :kind 0) (etypecase #S(sb-impl::comma :expr arg :kind 0) ((or string pathname) (open #S(sb-impl::comma :expr arg :kind 0))) (stream #S(sb-impl::comma :expr arg :kind 0)))))) (unwind-protect* (close #S(sb-impl::comma :expr stream :kind 0))))) (sb-int:quasiquote (let ((#S(sb-impl::comma :expr line :kind 0) (read-line #S(sb-impl::comma :expr stream :kind 0) nil nil))) (if #S(sb-impl::comma :expr line :kind 0) (setf #S(sb-impl::comma :expr var :kind 0) #S(sb-impl::comma :expr line :kind 0)) (end-for))))))))) (quote lines-of))
Write a Common Lisp macro to handle this code pattern:
(defun-compile-time valid-function-name? (function-name) (or (and (symbolp function-name) (not (null function-name))) (and (consp function-name) (eq (first function-name) 'setf) (null (rest (last function-name))) (= (length function-name) 2) (symbolp (second function-name)) (not (null (second 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 valid-function-name? (function-name) (or (and (symbolp function-name) (not (null function-name))) (and (consp function-name) (eq (first function-name) (quote setf)) (null (rest (last function-name))) (= (length function-name) 2) (symbolp (second function-name)) (not (null (second function-name)))))) (eval-when (:compile-toplevel) (compile (quote valid-function-name?))))
Define a macro that eliminates this repetitive pattern:
(define-value-binding table-values (var table &aux (iterator (hash-table-iterator table)) next key val) (declare (type hash-table table) (type function iterator)) `(multiple-value-bind (,next ,key ,val) (funcall ,iterator) (declare (ignore ,key)) (if ,next (update ,var ,val) (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 table-values (var table) (let ((#:iterator151 (gensym #A((8) base-char . "ITERATOR"))) (#:next152 (gensym #A((4) base-char . "NEXT"))) (#:key153 (gensym #A((3) base-char . "KEY"))) (#:val154 (gensym #A((3) base-char . "VAL"))) (#:table150 (gensym #A((5) base-char . "TABLE")))) (values* (sb-int:quasiquote (with-interleaving (let* #S(sb-impl::comma :expr (list* (list #:table150 table) (list #:iterator151 (list (quote hash-table-iterator) #:table150)) (list #:next152 nil) (list #:key153 nil) (list #:val154 nil) (loop for #:var149 in (lambda-fiddle:extract-lambda-vars (enlist var)) collect (list #:var149 nil))) :kind 0) (declare (ignorable #S(sb-impl::comma :expr #:iterator151 :kind 0) #S(sb-impl::comma :expr #:next152 :kind 0) #S(sb-impl::comma :expr #:key153 :kind 0) #S(sb-impl::comma :expr #:val154 :kind 0) #S(sb-impl::comma :expr #:table150 :kind 0))) #S(sb-impl::comma :expr (sb-int:quasiquote (declare (type #S(sb-impl::comma :expr (quote hash-table) :kind 0) #S(sb-impl::comma :expr #:table150 :kind 0)))) :kind 0) #S(sb-impl::comma :expr (sb-int:quasiquote (declare (type #S(sb-impl::comma :expr (quote function) :kind 0) #S(sb-impl::comma :expr #:iterator151 :kind 0)))) :kind 0)) #S(sb-impl::comma :expr nil :kind 0))) (let ((iterator #:iterator151) (next #:next152) (key #:key153) (val #:val154) (table #:table150)) (declare (ignorable iterator next key val table)) (sb-int:quasiquote (multiple-value-bind (#S(sb-impl::comma :expr next :kind 0) #S(sb-impl::comma :expr key :kind 0) #S(sb-impl::comma :expr val :kind 0)) (funcall #S(sb-impl::comma :expr iterator :kind 0)) (declare (ignore #S(sb-impl::comma :expr key :kind 0))) (if #S(sb-impl::comma :expr next :kind 0) (update #S(sb-impl::comma :expr var :kind 0) #S(sb-impl::comma :expr val :kind 0)) (end-for))))))))
You are a Common Lisp macro expert. Given this code pattern:
($slot 'some-name)

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

Macro definition:
(defmacro $SLOT ...)

Macroexpansion:
(get-slot 'some-name)
Define a macro that eliminates this repetitive pattern:
(define-element-maker :link "a" '(:xlink-href))

Issue: Macro call that should be transformed by define-element-maker

Macro definition:
(defmacro define-element-maker (element name required-attributes)
  `(progn
     (defmethod assert-required-attributes ((element (eql ,element)) attributes)
       (declare (ignore element))
       (unless (evenp (length attributes))
         (warn "attribute list may be missing data: ~A" attributes))
       (let ((missing (set-difference ,required-attributes attributes)))
	 (when missing
	   (error 'missing-attributes :message (format nil "~A missing attributes: ~{~A~^ ~}" ,element missing)))))
     (defmethod make-svg-element ((element (eql ,element)) attributes)
       (when *check-required-attributes*
         (assert-required-attributes element attributes))
       (make-instance 'svg-element :name ,name :attributes attributes))))

Macroexpansion:
(progn (defmethod assert-required-attributes ((element (eql :link)) attributes) (declare (ignore element)) (unless (evenp (length attributes)) (warn "attribute list may be missing data: ~A" attributes)) (let ((missing (set-difference (quote (:xlink-href)) attributes))) (when missing (error (quote missing-attributes) :message (format nil "~A missing attributes: ~{~A~^ ~}" :link missing))))) (defmethod make-svg-element ((element (eql :link)) attributes) (when *check-required-attributes* (assert-required-attributes element attributes)) (make-instance (quote svg-element) :name "a" :attributes attributes)))
Generate a defmacro form that transforms code like this:
(define-case-aware-token-p-function pp-defined-operator-p find-pp-operator-name with-c-syntax.preprocess-operator:|defined|)

Pattern to recognize: Macro call that should be transformed by define-case-aware-token-p-function

Macro definition:
(defmacro define-case-aware-token-p-function (function-name find-symbol-function symbol)
  `(defun ,function-name (token &optional (readtable-case (readtable-case *readtable*)))
     (and (symbolp token)
          (eq (,find-symbol-function (string token) readtable-case)
              ',symbol))))

Macroexpansion:
(defun pp-defined-operator-p (token &optional (readtable-case (readtable-case *readtable*))) (and (symbolp token) (eq (find-pp-operator-name (string token) readtable-case) (quote with-c-syntax.preprocess-operator:|defined|))))
Write a Common Lisp macro to handle this code pattern:
(without-symbol-access
  nil
  :key
  nil)

Problem: Macro call that should be transformed by WITHOUT-SYMBOL-ACCESS

Macro definition:
(defmacro WITHOUT-SYMBOL-ACCESS ...)

Macroexpansion:
(let ((*symbol-access* nil))
  nil
  :key
  nil)
Define a macro that eliminates this repetitive pattern:
(dotable (item _ set1) (add# item set))

Issue: Macro call that should be transformed by dotable

Macro definition:
(defmacro dotable ((k v table &optional rez) &body body)
  "Like DOLIST but iterates over key-value pairs (K V) in anything, that can be
   viewed as a table (hash-table, alist, plist, object).
   Autodeclares variables named _ as ignored."
  (with-gensyms (pair)
    (once-only (table)
      (let ((_ (find "_" (list k v)
                     :test 'string=
                     :key 'symbol-name)))
        `(block nil
           (etypecase ,table
             (hash-table (maphash (lambda (,k ,v)
                                    ,(when _ `(declare (ignore rutils.bind:_)))
                                    ,@body)
                                  ,table))

             (list (if (rutils.list:alistp ,table)
                       (dolist (,pair ,table)
                         (destructuring-bind (,k . ,v) ,pair
                           ,@(when _ `((declare (ignore ,_))))
                           ,@body))
                       (error 'simple-type-error
                              :format-control "Can't iterate over proper list ~
                                               in DOTABLE: need an alist"))))
           ,rez)))))

Macroexpansion:
(let ((#:table164 set1)) (block nil (etypecase #:table164 (hash-table (maphash (lambda (item _) (declare (ignore rutils.bind:_)) (|ADD#| item set)) #:table164)) (list (if (alistp #:table164) (dolist (#:g163 #:table164) (destructuring-bind (item . _) #:g163 (declare (ignore _)) (|ADD#| item set))) (error (quote simple-type-error) :format-control "Can't iterate over proper list ~
                                               in DOTABLE: need an alist")))) nil))
Generate a defmacro form that transforms code like this:
(lret ((out (make-array shape :element-type element-type))) (replace* (%flatten out) array))

Pattern to recognize: 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) array))
Create a Common Lisp macro for the following transformation. Before code:
(-> nil)

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

Macro definition:
(defmacro -> ...)

Macroexpansion:
nil
Write a Common Lisp macro to handle this code pattern:
(with-wrap-attempt ("extern ~S" name) name (let* ((*package* package) (extern (find-extern name)) (ptr-or-error `(or (cffi-sys:%foreign-symbol-pointer ,(foreign-symbol-c-symbol extern) :default) (error "Foreign extern symbol not found: ~S" ',name)))) (if (foreign-scalar-p (foreign-type extern)) `(define-symbol-macro ,name (cffi-sys:%mem-ref ,ptr-or-error ,(basic-foreign-type (foreign-type extern)))) `(define-symbol-macro ,name ,ptr-or-error))))

Problem: Macro call that should be transformed by with-wrap-attempt

Macro definition:
(defmacro with-wrap-attempt ((&optional format-control &rest format-args) wrappable-name &body body)
  `(call-with-wrap-attempt ,wrappable-name (lambda () ,@body) ,format-control (list ,@format-args)))

Macroexpansion:
(call-with-wrap-attempt name (lambda nil (let* ((*package* package) (extern (find-extern name)) (ptr-or-error (sb-int:quasiquote (or (cffi-sys:%foreign-symbol-pointer #S(sb-impl::comma :expr (foreign-symbol-c-symbol extern) :kind 0) :default) (error "Foreign extern symbol not found: ~S" (quote #S(sb-impl::comma :expr name :kind 0))))))) (if (foreign-scalar-p (foreign-type extern)) (sb-int:quasiquote (define-symbol-macro #S(sb-impl::comma :expr name :kind 0) (cffi-sys:%mem-ref #S(sb-impl::comma :expr ptr-or-error :kind 0) #S(sb-impl::comma :expr (basic-foreign-type (foreign-type extern)) :kind 0)))) (sb-int:quasiquote (define-symbol-macro #S(sb-impl::comma :expr name :kind 0) #S(sb-impl::comma :expr ptr-or-error :kind 0)))))) "extern ~S" (list name))
Generate a defmacro form that transforms code like this:
(enable-reader-syntax nil nil)

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

Macro definition:
(defmacro ENABLE-READER-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (push *readtable* *previous-readtables*)
  (setq *readtable* (copy-readtable))
  (%enable-reader-syntax *readtable* nil nil))
Create a Common Lisp macro for the following transformation. Before code:
(define-error name-unsuitable () (name) "Names of variables and functions must start with an alpha char. They also may not start with 'gl-' 'fk-' or 'sym-' Also, naturally, t and nil are not valid names Supplied Name: ~a~%" name)

What needs to change: 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 name-unsuitable (:error-type varjo-error :prefix "Varjo") (name) "Names of variables and functions must start with an alpha char. They also may not start with 'gl-' 'fk-' or 'sym-' Also, naturally, t and nil are not valid names Supplied Name: ~a~%" name)
Create a Common Lisp macro for the following transformation. Before code:
(the)

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

Macro definition:
(defmacro THE ...)

Macroexpansion:
(send self)
You are a Common Lisp macro expert. Given this code pattern:
(defsynonym repeating :repeat)

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

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

Macroexpansion:
(eval-always (setf (get (quote repeating) (quote synonym)) (quote :repeat)))