Save reformatted tangled Python buffer and tell it the user

This commit is contained in:
Gerard Vermeulen 2022-05-07 16:30:03 +02:00
parent 9fb6c6f0f3
commit 75e7f8b3f4

View File

@ -2591,12 +2591,14 @@ Listing [[lst:configure-format-all]]:
(when (fboundp 'format-all-ensure-formatter)
(add-hook 'prog-mode-hook #'format-all-ensure-formatter))
(add-hook 'org-babel-post-tangle-hook
(add-hook
'org-babel-post-tangle-hook
(defun format-all-org-babel-post-tangle ()
(when (derived-mode-p 'python-mode)
(setq-local format-all-formatters '(("Python" black)))
(message "Format whole `%s' buffer after tangling" major-mode)
(format-all-buffer)))))
(format-all-buffer)
(save-buffer)
(message "Saved reformatted tangled buffer `%s'" (buffer-file-name))))))
#+end_src
** [[https://dept-info.labri.fr/~strandh/Teaching/PFS/Common/Strandh-Tutorial/Dir-symbolic.html][Common Lisp programming]]