{"id":22686094,"url":"https://github.com/eschulte/lisp-format","last_synced_at":"2026-02-03T04:05:18.713Z","repository":{"id":39167685,"uuid":"137425252","full_name":"eschulte/lisp-format","owner":"eschulte","description":"A tool to format lisp code.  Designed to mimic clang-format.","archived":false,"fork":false,"pushed_at":"2022-02-16T23:06:53.000Z","size":47,"stargazers_count":52,"open_issues_count":3,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T15:31:53.450Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eschulte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-15T01:12:02.000Z","updated_at":"2025-03-08T01:48:46.000Z","dependencies_parsed_at":"2022-08-18T17:42:02.061Z","dependency_job_id":null,"html_url":"https://github.com/eschulte/lisp-format","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eschulte/lisp-format","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschulte%2Flisp-format","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschulte%2Flisp-format/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschulte%2Flisp-format/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschulte%2Flisp-format/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eschulte","download_url":"https://codeload.github.com/eschulte/lisp-format/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschulte%2Flisp-format/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261206115,"owners_count":23124838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-09T22:26:01.153Z","updated_at":"2026-02-03T04:05:13.690Z","avatar_url":"https://github.com/eschulte.png","language":"Emacs Lisp","readme":"# Lisp-Format --- A tool to format lisp code.\n\nThis lisp-format script aims to provide the same functionality as\nclang-format only for lisp languages instead of for C languages.\nEmacs is used to perform formatting.  The behavior of clang-format is\nfollowed as closely as possible with the goal of a direct drop in\nreplacement in most contexts.\n\nThis script is suitable for (re)formatting lisp code using an external\nprocess.  This script may be marked as executable and executed\ndirectly on the command line as follows.\n\n```shell\nchmod +x lisp-format\n./lisp-format -h\n```\n\nThis script is appropriate for use in git commit hooks, see\n[Running lisp-format git hooks](#running-lisp-format-git-hooks).\n\n## Customizing lisp-format\n\nClang-format allows for customized \"styles\" to be specified by\nwriting .clang-format files in the base of code repository and\npassing the -style=file flag to clang-format.  Lisp-format\nsupports the same using .lisp-format files.  These files may hold\narbitrary emacs-lisp code, and they will be loaded before every\nrun of lisp-format.  The following example file will (1) load\nslime assuming you have slime installed via quicklisp, (2) adjust\nthe syntax-table for special reader macro characters, and (3)\nspecify indentation for non-standard functions (e.g., from the\npopular common lisp Alexandria package).\n\n```lisp\n;;;; -*- emacs-lisp -*-\n(set-default 'indent-tabs-mode nil)\n(mapc (lambda (dir) (add-to-list 'load-path dir))\n      (directory-files\n       (concat (getenv \"QUICK_LISP\")\n               \"/dists/quicklisp/software/\") t \"slime-v*\"))\n(require 'slime)\n\n;;; Syntax table extension for curry-compose-reader-macros\n(modify-syntax-entry ?\\[ \"(]\" lisp-mode-syntax-table)\n(modify-syntax-entry ?\\] \")[\" lisp-mode-syntax-table)\n(modify-syntax-entry ?\\{ \"(}\" lisp-mode-syntax-table)\n(modify-syntax-entry ?\\} \"){\" lisp-mode-syntax-table)\n(modify-syntax-entry ?\\« \"(»\" lisp-mode-syntax-table)\n(modify-syntax-entry ?\\» \")«\" lisp-mode-syntax-table)\n\n;;; Specify indentation levels for specific functions.\n(mapc (lambda (pair) (put (first pair) 'lisp-indent-function (second pair)))\n      '((if-let 1)\n        (if-let* 1)))\n```\n\nAs described in the \"git lisp-format -h\" output, you can use \"git\nconfig\" to change the default style to \"file\" with the following\ncommand (run in a git repository).\n\n```shell\ngit config lispFormat.style \"file\"\n```\n\nRunning the above and adding a `.lisp-format` file to the base of a\ngit repository enables customization of the lisp-format behavior.\n\nCurrently lisp-format only exports a single configuration variable\nwhich may be customized to run fixers on formatted regions of code.\nSee the documentation of `*LISP-FORMAT-FIXERS**` for details.  For\nexample to remove all tabs add the following:\n\n```lisp\n;; NOTE: unless indent-tabs-mode is `set-default' to nil\n;; subsequent fixers after untabify could themselves add\n;; tabs.\n(set-default 'indent-tabs-mode nil)\n(push 'untabify *lisp-format-fixers*)\n```\n\n## User-specific customization\n\nUser-specific customization of lisp-format may be accomplished by\nwriting emacs-lisp code to an configuration file named\n`~/.lisp-formatrc` in the users home directory.  This may be useful\nfor adding directories to the load path searched by lisp-format.\n\n\n## Running lisp-format git hooks\n\nThe lisp-format script is appropriate for use in git commit hooks.  In\nfact the\n[git-clang-format script](https://raw.githubusercontent.com/llvm-mirror/clang/master/tools/clang-format/git-clang-format)\nmay be fairly trivially converted into a git-lisp-format script by\nreplacing \"clang\" with \"lisp\" and changing the in-scope file\nextensions as follows.\n\n```shell\ncurl -s https://raw.githubusercontent.com/llvm-mirror/clang/master/tools/clang-format/git-clang-format \\\n    |sed \\\n    \"s/clang-format/lisp-format/g;s/clangFormat/lispFormat/;\n     s/default_extensions =.*\\$/default_extensions = ','.join(['lisp','cl','asd','scm','el'])/;\n     /# From clang\\/lib\\/Frontend\\/FrontendOptions.cpp, all lower case/,/])/d\" \\\n    \u003e /usr/bin/git-lisp-format\n\nchmod +x /usr/bin/git-lisp-format\n```\n\nAfter the resulting git-lisp-format is added to your path then git can\nexecute this file by running \"git lisp-format.\"\n\nSee\n[setting up git clang format](https://dx13.co.uk/articles/2015/04/03/setting-up-git-clang-format/)\nfor an example description of a work flow leveraging git hooks and\ngit-clang-format to ensure that code is well formatted before every\ncommit (i.e., by writing the following shell code to an executable\nfile named `pre-commit` in a repository's `.git/hooks/` directory).\nThis work flow may be trivially adopted to use git-lisp-format for\nlispy code.\n\nIt is relatively easy to configure git to run lisp-format before every\ncommit, and reject commits which are not well formatted.  The\nfollowing two subsections describe how to do this using a [Pre-commit\nhook shell script](#pre-commit-hook-shell-script) or using the\n[Pre-commit framework](#pre-commit-framework).\n\n### Pre-commit hook shell script\n\n```shell\n#!/bin/bash\n# pre-commit shell script to run git-lisp-format.\nOUTPUT=$(git lisp-format --diff)\nif [ \"${OUTPUT}\" == \"no modified files to format\" ] ||\n   [ \"${OUTPUT}\" == \"lisp-format did not modify any files\" ];then\n    exit 0\nelse\n    echo \"Run git lisp-format, then commit.\"\n    exit 1\nfi\n```\n\n### Pre-commit framework\n\nThe `.pre-commit-hooks.yaml` file in this directory provides a\n[pre-commit framework](https://pre-commit.com/) hook for running\nlisp-format.  This hook requires the pre-commit framework to be\ninstalled on your system and configured for each git repository. For\nmore information please refer to:\n- [pre-commit installation](https://pre-commit.com/#install)\n- [pre-commit plugins](https://pre-commit.com/#plugins) (`.pre-commit-config.yaml`)\n- [pre-commit usage](https://pre-commit.com/#usage)\n- [pre-commit hook list](https://pre-commit.com/hooks.html)\n","funding_links":[],"categories":["Online editors ##"],"sub_categories":["Third-party APIs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feschulte%2Flisp-format","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feschulte%2Flisp-format","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feschulte%2Flisp-format/lists"}