diff --git a/emacs/init.org b/emacs/init.org index 3aaf0d3..9dd2fea 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -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!