Skip to content
Emacs package to reformat Python using black-macchiato
Branch: master
Clone or download
wbolster don't try to format empty statements
formatting an empty line results in empty reformatted output, and the
results was that the line will be deleted completely. now those empty
lines will be left as-is.
Latest commit b1f6e92 May 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.md add license May 14, 2019
README.md add python-black-statement: reformat the current statement (#1) May 15, 2019
python-black.el

README.md

python-black.el

This is an Emacs package to make it easy to reformat Python code using black, the uncompromising Python code formatter.

As an optional extra, this package can also reformat partial buffers using black-macchiato, which is a small wrapper around black which does just that.

Installation

Install the python-black Melpa package using M-x package-install, or via use-package:

(use-package python-black
  :demand t
  :after python)

Usage

Use one of these commands via M-x or bind them to a key:

  • python-black-buffer

    Reformat the current buffer.

  • python-black-region

    Reformat the current region. (Requires black-macchiato.)

  • python-black-statement

    Reformat the current statement. (Requires black-macchiato.)

  • python-black-on-save-mode

    Automatically reformat the buffer on save.

Configuration

This package deliberately has minimal configuration. Use M-x customize-group RET python-black or change these variables in your init.el:

  • python-black-command
  • python-black-macchiato-command
  • python-black-extra-args

To configure black itself, use an external configuration file for your project, which has the benefits that it can be per-project, and works outside Emacs as well.

License

BSD-3-clause. Copyright © 2019 wouter bolsterlee.

Credits

wouter bolsterlee. wbolster.

https://github.com/wbolster on github. star my repos. fork them. and so on.

https://twitter.com/wbolster on twitter. follow me. or say hi.

You can’t perform that action at this time.