feat(literate): add indent babel block helper

This adds a helper function, which can be used to auto indent all
emacs-lisp babel src blocks in the current file. It's intended to help
users to auto format their emacs-lisp blocks in their literate config,
improving the styling of each respective codeblock.
This commit is contained in:
Peter Farr 2025-08-15 20:16:52 -04:00
parent 4b3ef167aa
commit a2bcbd428f

View file

@ -166,6 +166,18 @@
(indent-region (point-min) (point-max)) (indent-region (point-min) (point-max))
(save-buffer))))) (save-buffer)))))
;;;###autoload
(defun +literate-indent-elisp-src-blocks ()
"Indent all emacs-lisp src blocks in the current Org buffer, then save."
(interactive)
(save-excursion
(org-babel-map-src-blocks nil
(when (string= lang "emacs-lisp")
(org-babel-do-in-edit-buffer
(emacs-lisp-mode)
(indent-region (point-min) (point-max)))))
(save-buffer)))
;; ;;
;;; Hooks ;;; Hooks