aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadon Rosborough <radon.neon@gmail.com>2019-07-17 11:24:22 -0700
committerRadon Rosborough <radon.neon@gmail.com>2019-07-17 11:26:52 -0700
commit903d6b810c57be4cdfadc002416aa60f34fe00f6 (patch)
tree7060547ac21862c553051e49129029d65ae8b41f
parent1258aa6a441726a3516206837cefb67e68cc4917 (diff)
Add apheleia-post-format-hook
-rw-r--r--README.md6
-rw-r--r--apheleia.el7
2 files changed, 12 insertions, 1 deletions
diff --git a/README.md b/README.md
index 0076408..a90b66e 100644
--- a/README.md
+++ b/README.md
@@ -89,6 +89,12 @@ the configured formatter for the current buffer. Running with a prefix
argument will cause the command to prompt you for which formatter to
run.
+The following user options are also available:
+
+* `apheleia-post-format-hook`: Normal hook run after Apheleia formats
+ a buffer. Run if the formatting is successful, even when no changes
+ are made to the buffer.
+
## Contributing
Development of Apheleia happens using the provided Makefile:
diff --git a/apheleia.el b/apheleia.el
index 2645426..9c5ad6a 100644
--- a/apheleia.el
+++ b/apheleia.el
@@ -565,6 +565,10 @@ changes), CALLBACK, if provided, is invoked with no arguments."
(when callback
(funcall callback)))))))))
+(defcustom apheleia-post-format-hook nil
+ "Normal hook run after Apheleia formats a buffer."
+ :type 'hook)
+
;; Handle recursive references.
(defvar apheleia-mode)
@@ -581,7 +585,8 @@ changes), CALLBACK, if provided, is invoked with no arguments."
(ignore-errors
(let ((after-save-hook
(remq #'apheleia--format-after-save after-save-hook)))
- (apheleia--write-file-silently buffer-file-name))))))))
+ (apheleia--write-file-silently buffer-file-name)
+ (run-hooks 'apheleia-post-format-hook))))))))
;; Use `progn' to force the entire minor mode definition to be copied
;; into the autoloads file, so that the minor mode can be enabled