Function: apheleia-format-after-save

apheleia-format-after-save is a natively compiled function defined in apheleia.el.

Signature

(apheleia-format-after-save)

Documentation

Run code formatter for current buffer if any configured, then save.

Source Code

;; Defined in /nix/store/lwcwryzabcmvjcwwzzs65jrwf7p7d7cs-emacs-packages-deps/share/emacs/site-lisp/elpa/apheleia-20260915.1628/apheleia.el
;; Autoload because the user may enable `apheleia-mode' without
;; loading Apheleia; thus this function may be invoked as an autoload.
;;;###autoload
(defun apheleia-format-after-save ()
  "Run code formatter for current buffer if any configured, then save."
  (unless apheleia-format-after-save-in-progress
    (when (and apheleia-mode (not (buffer-narrowed-p)))
      (when-let* ((formatters (apheleia--get-formatters)))
        (apheleia-format-buffer
         formatters
         (lambda ()
           (with-demoted-errors "Apheleia: %s"
             (when buffer-file-name
               (let ((apheleia-format-after-save-in-progress t))
                 (apheleia--save-buffer-silently)))
             (run-hooks 'apheleia-post-format-hook))))))))