From a2bcbd428fb69a068a84b9339c57cb6f37fa5c66 Mon Sep 17 00:00:00 2001 From: Peter Farr Date: Fri, 15 Aug 2025 20:16:52 -0400 Subject: [PATCH] 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. --- modules/config/literate/autoload.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/config/literate/autoload.el b/modules/config/literate/autoload.el index f88de92c3..fe7438e23 100644 --- a/modules/config/literate/autoload.el +++ b/modules/config/literate/autoload.el @@ -166,6 +166,18 @@ (indent-region (point-min) (point-max)) (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