cl-ds / data /extractions /cl-forms_extractions.jsonl
j14i's picture
3375 CL macro transformation examples from 85 libraries
43203b4 verified
{"id": "cl-forms-with-gensyms", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/docs/colorize-lisp-examples.lisp", "macro_name": "with-gensyms", "macro_definition": "(defmacro with-gensyms ((&rest names) &body body)\n `(let ,(mapcar #'(lambda (name)\n (list name `(make-symbol ,(symbol-name name)))) names)\n ,@body))", "form_type": "defmacro", "docstring": null, "args": "((&rest names) &body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-with-scanning-functions", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/docs/colorize-lisp-examples.lisp", "macro_name": "with-scanning-functions", "macro_definition": "(defmacro with-scanning-functions (string-param position-place mode-place mode-wait-place &body body)\n (with-gensyms (num items position not-preceded-by string item new-mode until advancing)\n `(labels ((advance (,num)\n (setf ,position-place (+ ,position-place ,num))\n t)\n (peek-any (,items &key ,not-preceded-by)\n (incf *scan-calls*)\n (let* ((,items (if (stringp ,items)\n (coerce ,items 'list) ,items))\n (,not-preceded-by (if (characterp ,not-preceded-by)\n (string ,not-preceded-by) ,not-preceded-by))\n (,position ,position-place)\n (,string ,string-param))\n (let ((,item (and\n (< ,position (length ,string))\n (find ,string ,items\n :test #'(lambda (,string ,item)\n #+nil\n (format t \"looking for ~S in ~S starting at ~S~%\"\n ,item ,string ,position)\n (if (characterp ,item)\n (char= (elt ,string ,position)\n ,item)\n (search ,item ,string :start2 ,position\n :end2 (min (length ,string)\n (+ ,position (length ,item))))))))))\n (if (characterp ,item)\n (setf ,item (string ,item)))\n (if\n (if ,item\n (if ,not-preceded-by\n (if (>= (- ,position (length ,not-preceded-by)) 0)\n (not (string= (subseq ,string\n (- ,position (length ,not-preceded-by))\n ,position)\n ,not-preceded-by))\n t)\n t)\n nil)\n ,item\n (progn\n (and *reset-position*\n (setf ,position-place *reset-position*))\n nil)))))\n (scan-any (,items &key ,not-preceded-by)\n (let ((,item (peek-any ,items :not-preceded-by ,not-preceded-by)))\n (and ,item (advance (length ,item)))))\n (peek (,item &key ,not-preceded-by)\n (peek-any (list ,item) :not-preceded-by ,not-preceded-by))\n (scan (,item &key ,not-preceded-by)\n (scan-any (list ,item) :not-preceded-by ,not-preceded-by)))\n (macrolet ((set-mode (,new-mode &key ,until (,advancing t))\n (list 'progn\n (list 'setf ',mode-place ,new-mode)\n (list 'setf ',mode-wait-place\n (list 'lambda (list ',position)\n (list 'let (list (list '*reset-position* ',position))\n (list 'values ,until ,advancing)))))))\n ,@body))))", "form_type": "defmacro", "docstring": null, "args": "(string-param position-place mode-place mode-wait-place &body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-define-coloring-type", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/docs/colorize-lisp-examples.lisp", "macro_name": "define-coloring-type", "macro_definition": "(defmacro define-coloring-type (name fancy-name &key modes default-mode transitions formatters\n autodetect parent formatter-variables (formatter-after-hook '(constantly \"\"))\n invisible)\n (with-gensyms (parent-type term type string current-mode position position-foobage mode-wait new-position advance)\n `(let ((,parent-type (or (find-coloring-type ,parent)\n (and ,parent\n (error \"No such coloring type: ~S\" ,parent)))))\n (setf (find-coloring-type ,name)\n (make-instance 'coloring-type\n :fancy-name ',fancy-name\n :modes (append ',modes (if ,parent-type (coloring-type-modes ,parent-type)))\n :default-mode (or ',default-mode\n (if ,parent-type (coloring-type-default-mode ,parent-type)))\n ,@(if autodetect\n `(:autodetect-function ,autodetect))\n :parent-type ,parent-type\n :visible (not ,invisible)\n :formatter-initial-values (lambda nil\n (list* ,@(mapcar #'(lambda (e)\n `(cons ',(car e) ,(second e)))\n formatter-variables)\n (if ,parent-type\n (funcall (coloring-type-formatter-initial-values ,parent-type))\n nil)))\n :formatter-after-hook (lambda nil\n (symbol-macrolet ,(mapcar #'(lambda (e)\n `(,(car e) (cdr (assoc ',(car e) *formatter-local-variables*))))\n formatter-variables)\n (concatenate 'string\n (funcall ,formatter-after-hook)\n (if ,parent-type\n (funcall (coloring-type-formatter-after-hook ,parent-type))\n \"\"))))\n :term-formatter\n (symbol-macrolet ,(mapcar #'(lambda (e)\n `(,(car e) (cdr (assoc ',(car e) *formatter-local-variables*))))\n formatter-variables)\n (lambda (,term)\n (labels ((call-parent-formatter (&optional (,type (car ,term))\n (,string (cdr ,term)))\n (if ,parent-type\n (funcall (coloring-type-term-formatter ,parent-type)\n (cons ,type ,string))))\n (call-formatter (&optional (,type (car ,term))\n (,string (cdr ,term)))\n (funcall\n (case (first ,type)\n ,@formatters\n (t (lambda (,type text)\n (call-parent-formatter ,type text))))\n ,type ,string)))\n (call-formatter))))\n :transition-functions\n (list\n ,@(loop for transition in transitions\n collect (destructuring-bind (mode &rest table) transition\n `(cons ',mode\n (lambda (,current-mode ,string ,position)\n (let ((,mode-wait (constantly nil))\n (,position-foobage ,position))\n (with-scanning-functions ,string ,position-foobage\n ,current-mode ,mode-wait\n (let ((*reset-position* ,position))\n (cond ,@table))\n (values ,position-foobage ,current-mode\n (lambda (,new-position)\n (setf ,position-foobage ,new-position)\n (let ((,advance (nth-value 1 (funcall ,mode-wait ,position-foobage))))\n (values ,position-foobage ,advance)))))\n )))))))))))", "form_type": "defmacro", "docstring": null, "args": "(name fancy-name &key modes default-mode transitions formatters\n autodetect parent formatter-variables (formatter-after-hook '(constantly \"\"))\n invisible)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-with-each-stream-line", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/docs/colorize-lisp-examples.lisp", "macro_name": "with-each-stream-line", "macro_definition": "(defmacro with-each-stream-line ((var stream) &body body)\n (let ((eof (gensym))\n (eof-value (gensym))\n (strm (gensym)))\n `(let ((,strm ,stream)\n (,eof ',eof-value))\n (do ((,var (read-line ,strm nil ,eof) (read-line ,strm nil ,eof)))\n ((eql ,var ,eof))\n ,@body))))", "form_type": "defmacro", "docstring": null, "args": "((var stream) &body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-string-append", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/docs/colorize-lisp-examples.lisp", "macro_name": "string-append", "macro_definition": "(defmacro string-append (outputstr &rest args)\n `(setq ,outputstr (concatenate 'string ,outputstr ,@args)))", "form_type": "defmacro", "docstring": null, "args": "(outputstr &rest args)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-with-form-renderer", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/src/cl-forms.lisp", "macro_name": "with-form-renderer", "macro_definition": "(defmacro with-form-renderer (renderer &body body)\n \"Bind *FORM-RENDERER* to RENDERER and evaluate BODY in that context.\"\n `(call-with-form-renderer ,renderer (lambda () ,@body)))", "form_type": "defmacro", "docstring": "Bind *FORM-RENDERER* to RENDERER and evaluate BODY in that context.", "args": "(renderer &body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-with-form-theme", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/src/cl-forms.lisp", "macro_name": "with-form-theme", "macro_definition": "(defmacro with-form-theme (form-theme &body body)\n \"Bind *FORM-THEME* to FORM-THEME and evaluate BODY in that context.\"\n `(call-with-form-theme ,form-theme (lambda () ,@body)))", "form_type": "defmacro", "docstring": "Bind *FORM-THEME* to FORM-THEME and evaluate BODY in that context.", "args": "(form-theme &body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-with-form", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/src/cl-forms.lisp", "macro_name": "with-form", "macro_definition": "(defmacro with-form (form &body body)\n \"Bind *FORM* to FORM and evaluate BODY in that context.\"\n `(call-with-form ,form (lambda () ,@body)))", "form_type": "defmacro", "docstring": "Bind *FORM* to FORM and evaluate BODY in that context.", "args": "(form &body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-defform", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/src/cl-forms.lisp", "macro_name": "defform", "macro_definition": "(defmacro defform (form-name args fields)\n \"Define a form at top-level.\n\nARGS are the arguments passed to FORM class via MAKE-INSTANCE.\nFIELDS are the form field specs.\n\n@lisp\n(forms:defform client-validated-form (:action \\\"/client-validation-post\\\"\n :client-validation t)\n ((name :string :value \\\"\\\" :constraints (list (clavier:is-a-string)\n (clavier:not-blank)\n (clavier:len :max 5))\n :validation-triggers '(:focusin))\n (single :boolean :value t)\n (sex :choice :choices (list \\\"Male\\\" \\\"Female\\\") :value \\\"Male\\\")\n (age :integer :constraints (list (clavier:is-an-integer)\n (clavier:greater-than -1)\n (clavier:less-than 200)))\n (email :email)\n (submit :submit :label \\\"Create\\\")))\n@end lisp\"\n (check-duplicate-fields fields)\n (alexandria:with-gensyms (fargs)\n `(setf (get ',form-name :form)\n (lambda (&rest ,fargs)\n (apply #'make-instance\n 'form\n :name ',form-name\n :fields (list ,@(loop for field in fields\n collect\n (destructuring-bind (field-name field-type &rest field-args) field\n `(cons ',field-name (make-form-field ,field-type :name ',(intern (string field-name)) ,@field-args)))))\n (append ,fargs\n (list ,@args)))))))", "form_type": "defmacro", "docstring": "Define a form at top-level.\n\nARGS are the arguments passed to FORM class via MAKE-INSTANCE.\nFIELDS are the form field specs.\n\n@lisp\n(forms:defform client-validated-form (:action \\\"/client-validation-post\\\"\n :client-validation t)\n ((name :string :value \\\"\\\" :constraints (list (clavier:is-a-string)\n (clavier:not-blank)\n (clavier:len :max 5))\n :validation-triggers '(:focusin))\n (single :boolean :value t)\n (sex :choice :choices (list \\\"Male\\\" \\\"Female\\\") :value \\\"Male\\\")\n (age :integer :constraints (list (clavier:is-an-integer)\n (clavier:greater-than -1)\n (clavier:less-than 200)))\n (email :email)\n (submit :submit :label \\\"Create\\\")))\n@end lisp", "args": "(form-name args fields)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-defform-builder", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/src/cl-forms.lisp", "macro_name": "defform-builder", "macro_definition": "(defmacro defform-builder (form-name args &body body)\n \"Registers a function with arguments ARGS and body BODY as a form builder.\n\nBODY is expected to instantiate a FORM object using ARGS in some way.\n\nFORM-NAME is the symbol under which the FORM is registered.\n\nUse FIND-FORM with FORM-NAME and expected arguments to obtain the registered form.\"\n (alexandria:with-unique-names (form)\n `(setf (get ',form-name :form)\n (lambda ,args\n (let ((,form (progn ,@body)))\n (check-type ,form forms:form)\n (setf (form-name ,form) ',form-name)\n ,form)))))", "form_type": "defmacro", "docstring": "Registers a function with arguments ARGS and body BODY as a form builder.\n\nBODY is expected to instantiate a FORM object using ARGS in some way.\n\nFORM-NAME is the symbol under which the FORM is registered.\n\nUse FIND-FORM with FORM-NAME and expected arguments to obtain the registered form.", "args": "(form-name args &body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-with-form-fields", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/src/cl-forms.lisp", "macro_name": "with-form-fields", "macro_definition": "(defmacro with-form-fields (fields form &body body)\n \"Bind FIELDS to the form fields in FORM.\n\nExample:\n\n@lisp\n(with-form-fields (name) form\n (print (field-value name)))\n@end lisp\n\nAlso see: WITH-FORM-FIELD-VALUES \"\n `(let ,(loop for field in fields\n collect `(,field (get-field ,form ',field)))\n ,@body))", "form_type": "defmacro", "docstring": "Bind FIELDS to the form fields in FORM.\n\nExample:\n\n@lisp\n(with-form-fields (name) form\n (print (field-value name)))\n@end lisp\n\nAlso see: WITH-FORM-FIELD-VALUES ", "args": "(fields form &body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-with-form-field-values", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/src/cl-forms.lisp", "macro_name": "with-form-field-values", "macro_definition": "(defmacro with-form-field-values (fields form &body body)\n \"Bind the value of FIELDS in FORM.\n\nExample:\n\n@lisp\n(with-form-field-values (name) form\n (print name))\n@end lisp\"\n `(let ,(loop for field in fields\n collect `(,field (field-value (get-field ,form ',field))))\n ,@body))", "form_type": "defmacro", "docstring": "Bind the value of FIELDS in FORM.\n\nExample:\n\n@lisp\n(with-form-field-values (name) form\n (print name))\n@end lisp", "args": "(fields form &body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-with-form-template", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/src/cl-forms.lisp", "macro_name": "with-form-template", "macro_definition": "(defmacro with-form-template ((&optional form-var) form-name args &body body)\n \"Define a FORM named FORM-NAME and render it at the same time.\"\n (multiple-value-bind (new-body fields) (collect-replace-fields body)\n (let ((form-bind (or form-var (gensym \"FORM\"))))\n `(progn\n (defform ,form-name ,args\n ,fields)\n (let ((,form-bind (or ,form-var (find-form ',form-name))))\n (with-form ,form-bind\n (render-form-start)\n ,@new-body\n (render-form-end)))))))", "form_type": "defmacro", "docstring": "Define a FORM named FORM-NAME and render it at the same time.", "args": "((&optional form-var) form-name args &body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}
{"id": "cl-forms-with-form-html-output", "library_name": "cl-forms", "system_name": "cl-forms", "source_file": "data/repos/cl-forms/src/renderer/who.lisp", "macro_name": "with-form-html-output", "macro_definition": "(defmacro with-form-html-output (&body body)\n `(who:with-html-output (*html* (or *html*\n\t\t\t\t (error \"FORMS.WHO:*HTML* is unbound. Please bind it before rendering forms. See FORMS.WHO:*HTML* documentation.\")))\n ,@body))", "form_type": "defmacro", "docstring": null, "args": "(&body body)", "extracted_at": "2026-05-09T08:49:47.256340+00:00", "status": "extracted"}