Skip to content

Commit d6814ca

Browse files
committed
Add information about using Emacs with darker
Add information on how to use emacs with darker using https://github.com/purcell/emacs-reformatter/ library Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent 0d83595 commit d6814ca

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.rst

+29
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,35 @@ You can though ask vim to run ``darker`` on file save with the following in your
490490

491491
Vim should automatically reload the file.
492492

493+
Emacs
494+
-----
495+
496+
You can integrate with Emacs using Steve Purcell's `emacs-reformatter`__ library.
497+
498+
Using `use-package`__:
499+
500+
.. code-block:: emacs-lisp
501+
502+
(use-package reformatter
503+
:hook ((python-mode . darker-reformat-on-save-mode))
504+
:config
505+
(reformatter-define darker-reformat
506+
:program "darker"
507+
:stdin nil
508+
:stdout nil
509+
:args (list "-q" input-file))
510+
511+
512+
This will automatically reformat the buffer on save.
513+
514+
You have multiple functions available to launch it manually:
515+
516+
- darker-reformat
517+
- darker-reformat-region
518+
- darker-reformat-buffer
519+
520+
__ https://github.com/purcell/emacs-reformatter
521+
__ https://github.com/jwiegley/use-package
493522

494523
Using as a pre-commit hook
495524
==========================

0 commit comments

Comments
 (0)