Ensure to format Python code after tangling
This commit is contained in:
parent
6cd9ed7ecd
commit
944e194758
20
README.org
20
README.org
@ -2560,19 +2560,29 @@ Listing [[lst:configure-writegood-mode]] configures [[https://github.com/bnbeckw
|
||||
:CUSTOM_ID: sec:format-all
|
||||
:END:
|
||||
|
||||
Listing [[lst:configure-format-all]] configures [[https://github.com/lassik/emacs-format-all-the-code#readme][format-all]] which is a package that
|
||||
provides an universal interface to code formatters of more than 60 computer
|
||||
languages.
|
||||
Listing [[lst:configure-format-all]]:
|
||||
1. Configures [[https://github.com/lassik/emacs-format-all-the-code#readme][format-all]] which is a package that provides an universal interface
|
||||
to code formatters of more than 60 computer languages.
|
||||
2. Adds =format-all-org-babel-post-tangle= to =org-babel-post-tangle-hook= to
|
||||
format tangled Python code.
|
||||
|
||||
#+caption[Configure =format-all=]:
|
||||
#+caption: Configure =format-all=.
|
||||
#+name: lst:configure-format-all
|
||||
#+begin_src emacs-lisp
|
||||
;; https://ianyepan.github.io/posts/format-all/
|
||||
;; https://github.com/lassik/emacs-format-all-the-code#readme
|
||||
;; https://ianyepan.github.io/posts/format-all/
|
||||
;; https://jamesaimonetti.com/posts/formatting-tangled-output-in-org-mode/
|
||||
(when (ensure-package-installation 'format-all)
|
||||
(when (fboundp 'format-all-ensure-formatter)
|
||||
(add-hook 'prog-mode-hook #'format-all-ensure-formatter)))
|
||||
(add-hook 'prog-mode-hook #'format-all-ensure-formatter))
|
||||
|
||||
(add-hook 'org-babel-post-tangle-hook
|
||||
(defun format-all-org-babel-post-tangle ()
|
||||
(when (derived-mode-p 'python-mode)
|
||||
(let ((format-all-formatters '(("Python" black))))
|
||||
(message "Format whole `%s' buffer after tangling" major-mode)
|
||||
(format-all-buffer))))))
|
||||
#+end_src
|
||||
|
||||
** [[https://dept-info.labri.fr/~strandh/Teaching/PFS/Common/Strandh-Tutorial/Dir-symbolic.html][Common Lisp programming]]
|
||||
|
Loading…
Reference in New Issue
Block a user