• Stars
    star
    589
  • Rank 73,598 (Top 2 %)
  • Language
    Emacs Lisp
  • License
    MIT License
  • Created about 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Auto-format source code in many languages with one command

format-all for Emacs

NOTE: The package is actively maintained but due to lack of time, complex tasks are done at a slow pace. Simple tasks like adding or fixing formatter definitions are often done immediately. For faster progress, additional maintainers are welcome.

What does it do

Lets you auto-format source code in many languages using the same command for all languages, instead of learning a different Emacs package and formatting command for each language.

Just do M-x format-all-region-or-buffer and it will try its best to do the right thing. To auto-format code on save, use the minor mode format-all-mode. Please see the documentation for that function for instructions.

Supported languages

How to install

From MELPA

You will need to install external programs to do the formatting. If format-all-buffer can't find the right program, it will try to tell you how to install it.

If you have installed a formatter but Emacs cannot find it, Emacs may be using a PATH different from your shell. The path searched by Emacs is in the exec-path variable. You can easily make it match your shell's PATH using the exec-path-from-shell package from MELPA.

How to customize

M-x customize-group format-all has a few basic settings.

However, the main thing you probably want to set is format-all-formatters. That variable is buffer-local, and can be made project-local by setting it in a .dir-locals.el file in a project's directory. That file can be committed to version control to share it with the whole project.

To enable format on save for most programming language buffers: (add-hook 'prog-mode-hook 'format-all-mode).

To control displaying the formatting errors buffer when formatting fails or has warnings, customize the variable format-all-show-errors. Set it to one of these - 'always (shows errors buffer regardless),'warnings (shows errors buffer for both errors and warnings), 'errors (only show errors buffer when there are errors) or 'never (never show errors buffer).

The command format-all-ensure-formatter will ensure that a default formatter is selected in case you don't have one set; you can customize the default formatter for each language. To ensure a formatter is set whenever you enable format-all-mode, you can use: (add-hook 'format-all-mode-hook 'format-all-ensure-formatter).

Additionally, many of the external formatters support configuration files in the source code directory to control their formatting. Please see the documentation for each formatter.

How to add new languages

New external formatters can be added easily if they can read code from standard input and format it to standard output. Feel free to submit a pull request or ask for help in GitHub issues.

How to report bugs

GitHub issues are preferred. Email is also ok.

Feature requests are welcome. If you are interested in doing anything beyond adding new formatters in the current framework, please discuss in issues before writing code.

Roadmap

atom-beautify sports a very impressive set of formatters. We should aspire to that level of coverage for Emacs.

Unibeautify is a project to provide one shell command to run all beautifiers. atom-beautify will be rewritten to be based on it. Perhaps we should be too, once it stabilizes.

More Repositories

1

shm_open_anon

Portable shm_open() without filename
C
29
star
2

awesome-forth

Resources and links for the Forth programming language
28
star
3

emacs-cowsay

Port of cowsay to pure Emacs Lisp
Emacs Lisp
13
star
4

emacs-live-preview

Live preview by any shell command while editing
Emacs Lisp
12
star
5

phpbb-ext-telegramnotifications

Notify on Telegram whenever someone posts on phpBB
PHP
11
star
6

emacs-language-id

Emacs Lisp library to work with programming language identifiers
Emacs Lisp
11
star
7

emacs-ascii-table

Interactive ASCII table in Emacs
Emacs Lisp
9
star
8

web-midi-chord-finder

Real-time display of chords you play on your MIDI instrument
Elm
8
star
9

upscheme

Scheme
6
star
10

laesare

R6RS/R7RS reader in R6RS Scheme
Scheme
4
star
11

racket-r7rs-example

How to use R7RS Scheme libraries in a Racket program
Racket
4
star
12

emacs-c-eval

Compile and run one-off C code snippets
Emacs Lisp
4
star
13

emacs-whois

Extends the whois functionality of Emacs
Emacs Lisp
4
star
14

scheme-snowtar

Tar library for Scheme
Scheme
3
star
15

scheme-gemini

Scheme library for the Gemini network protocol
Scheme
3
star
16

cl-seqlist

Makes the CL list functions work with all sequences
Common Lisp
3
star
17

homebrew-lisp

Tap for Lisp/Scheme/Clojure stuff that can't make it to Homebrew core
Ruby
3
star
18

elforth

The determined Real Programmer can write Forth in any language
Emacs Lisp
3
star
19

scheme

Personal Scheme libraries
Scheme
3
star
20

ansible-genera

Setup a Debian/amd64 VM to emulate a Symbolics Lisp machine
3
star
21

emacs-desktop-mail-user-agent

Use Linux/Windows/Mac mail program to send mail from Emacs
Emacs Lisp
3
star
22

giles

Growing Intertribal Lisp Expression (Symbolic)
2
star
23

clojure-for-common-lispers

Clojure tutorial and cheat sheet for people who know Common Lisp well
Shell
2
star
24

emacs-symbolist

List and interactively unbind Emacs Lisp symbols
Emacs Lisp
2
star
25

elm-webmidi-ports-minimal

Minimal working example of receiving Web MIDI messages in Elm 0.18
Elm
2
star
26

musical-scale-converter

Convert chords to Roman numeral notation
Elm
2
star
27

editorconfig-emacs-domain-specific

Apply domain-specific EditorConfig properties in Emacs
Emacs Lisp
2
star
28

scheme-identifier-lists

RnRS
Scheme
2
star
29

emacs-teletext

Read teletext pages in Emacs
Emacs Lisp
2
star
30

musical-scale-display

Elm
2
star
31

ragtag

Music tagger for a messy world
Elm
2
star
32

evilfinder

Maintenance fork of evilfinder
C
1
star
33

every-posix-feature

Aspires to list everything POSIX can do, as benchmark for people who reinvent it
1
star
34

scratch

Hacky first attempt to turn Edwin Emacs into portable R7RS code
Scheme
1
star
35

shelf

Shell Forth
1
star
36

emacs-define-scratch

Define new commands to make scratch buffers
Emacs Lisp
1
star
37

pathy

Work with PATH and similar envars in the shell
Standard ML
1
star
38

oldnewthing

Index of Raymond Chen's blog "The Old New Thing"
Python
1
star
39

emacs-currency-convert

Currency converter in Emacs
Emacs Lisp
1
star
40

emacs-posix-manual

POSIX manual page lookup from Emacs
Emacs Lisp
1
star
41

home

Home directory with personal configuration files
Emacs Lisp
1
star
42

massikone

Yhdistyksen kirjanpito netissΓ€
Go
1
star
43

chicken-srfi-193

Chicken egg for SRFI 193: Command line
Scheme
1
star
44

lookup-computer

Lookup tables for computer-related stuff
Python
1
star
45

emacs-file-magic-mode

Major mode for Unix file(1) magic patterns
Emacs Lisp
1
star
46

awesome-userland

Awesome userland tools
1
star
47

bitfont

Extremely simple file format for bitmap fonts
C
1
star
48

compression-library-usage

C
1
star
49

emacs-insert-random

Insert random characters from various character sets
Emacs Lisp
1
star
50

jersey

Standard Unix tools in Standard ML
Standard ML
1
star
51

musical-scale-speaker

Speaks scale degrees as you play them using Web MIDI and speech synthesis
Elm
1
star
52

fern

Functional Unix shell prioritising a simple and elegant language above all
Scheme
1
star
53

racket-database-url

Get database connection from DATABASE_URL environment variable
Racket
1
star
54

unix-flags

JSON database of command line options in Unix utilities
Scheme
1
star
55

midi-learn

Machine learning from MIDI input
Clojure
1
star
56

pandoc-tar

Batch conversion of documents (tar in, tar out)
Haskell
1
star
57

ansible-role-haskell-stack

Install Haskell Stack on Linux
1
star
58

lookup

Look up things from csv tables on the command line
Go
1
star
59

scheme-pandoc

Pandoc library for Scheme
Scheme
1
star
60

gdbmexport

Easy-to-build repo of GNU gdbmexport tool
C
1
star
61

simile

Scheme in ML
Standard ML
1
star
62

extensionless

Life without filename extensions
1
star
63

nada

Toy Nix in Scheme
Scheme
1
star
64

hyperspotting

All known versions of the Common Lisp HyperSpec
HTML
1
star