Add function to run black on buffer/region

This commit is contained in:
Jeremy Dormitzer 2019-11-04 17:09:01 -05:00
parent ce0321e9f1
commit 2d96cc2586

View File

@ -1354,6 +1354,17 @@ A function to run a pipenv-aware python repl:
(run-python nil nil t))
#+END_SRC
Run black on the current buffer:
#+BEGIN_SRC emacs-lisp
(defun blacken ()
(interactive)
(let ((start (if (use-region-p) (region-beginning) (point-min)))
(end (if (use-region-p) (region-end) (point-max))))
(shell-command-on-region start end "black -q -" nil t)))
(general-def 'normal python-mode-map "C-M-\\" #'blacken)
#+END_SRC
* Hy
Python but Lispy!