Add clar-format-all-formatter to allow user selections

This commit is contained in:
Gerard Vermeulen 2025-02-06 12:56:25 +01:00
parent 00bc3ff578
commit 3f061da8cd

View File

@ -3736,6 +3736,7 @@ Listing [[lst:configure-format-all]]:
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.
3. Adds =clear-format-all-formatter= to reset ~format-all~ user selections.
#+caption[Configure =format-all=]:
#+caption: Configure =format-all=.
@ -3745,7 +3746,6 @@ Listing [[lst:configure-format-all]]:
;; https://ianyepan.github.io/posts/format-all/
;; https://jamesaimonetti.com/posts/formatting-tangled-output-in-org-mode/
(when (ensure-package-installation 'format-all)
;; `format-all' defines `format-all-buffer' as an autoloaded command.
(with-eval-after-load 'ob-tangle
(add-hook
'org-babel-post-tangle-hook
@ -3755,7 +3755,14 @@ Listing [[lst:configure-format-all]]:
(format-all-buffer)
(save-buffer)
(message "Saved reformatted tangled buffer `%s'"
(buffer-file-name)))))))
(buffer-file-name))))))
(defun clear-format-all-formatter ()
"Clear the `format-all' selection to allow user selections."
(interactive)
(if format-all-formatters
(setq-local format-all-formatters nil)
(message "No `format-all' selection!"))))
#+end_src
** [[info:flymake#Top][Flymake (info)]]