From 0d6d58999899831edb313b0b4988cc7286ffcc8d Mon Sep 17 00:00:00 2001
From: Case Duckworth
Date: Fri, 15 Jul 2022 11:26:30 -0500
Subject: meh

---
 lisp/+apheleia.el | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

(limited to 'lisp')

diff --git a/lisp/+apheleia.el b/lisp/+apheleia.el
index 9ed731c..3428a72 100644
--- a/lisp/+apheleia.el
+++ b/lisp/+apheleia.el
@@ -3,6 +3,7 @@
 ;;; Code:
 
 (require 'cl-lib)
+(require 'user-save)
 
 ;; https://github.com/raxod502/apheleia/pull/63#issue-1077529623
 (cl-defun +apheleia-indent-region (&key buffer scratch formatter callback &allow-other-keys)
@@ -13,5 +14,18 @@
                    (point-max))
     (funcall callback)))
 
+(define-minor-mode +apheleia/user-save-mode
+  "Minor mode for reformatting code on `user-save'.
+Customize with `apheleia-mode-alist' and `apheleia-formatters'."
+  :lighter " Apheleia/US"
+  (if +apheleia/user-save-mode
+      (add-hook 'user-save-hook #'apheleia--format-after-save nil 'local)
+    (remove-hook 'user-save-hook #'apheleia--format-after-save 'local)))
+
+(define-globalized-minor-mode +apheleia/user-save-global-mode
+  +apheleia/user-save-mode  +apheleia/user-save-mode)
+
+(put '+apheleia/user-save-mode 'safe-local-variable #'booleanp)
+
 (provide '+apheleia)
 ;;; +apheleia.el ends here
-- 
cgit 1.4.1-21-gabe81