aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadon Rosborough <radon.neon@gmail.com>2019-07-10 22:17:34 -0700
committerRadon Rosborough <radon.neon@gmail.com>2019-07-10 22:17:34 -0700
commit55ee664caa2c9de2ff61d7f34b2ba1fc49acb4dd (patch)
tree5988b98996fcfdcbe95af4ab56ef045a12aba3f5
parentef86b0c4a3c2a92be82d31235c315ee4c31ecb22 (diff)
Backwards compatibility for (buffer-hash)
-rw-r--r--apheleia.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/apheleia.el b/apheleia.el
index 67d5ce7..6fc1050 100644
--- a/apheleia.el
+++ b/apheleia.el
@@ -494,6 +494,12 @@ even if a formatter is configured."
(user-error "No configuration for formatter `%S'"
formatter))))
+(defun apheleia--buffer-hash ()
+ "Compute hash of current buffer."
+ (if (fboundp 'buffer-hash)
+ (buffer-hash)
+ (md5 (current-buffer))))
+
(defvar apheleia--buffer-hash nil
"Return value of `buffer-hash' when formatter started running.")
@@ -536,16 +542,16 @@ changes), CALLBACK, if provided, is invoked with no arguments."
(if current-prefix-arg
'prompt
'interactive))))
- (setq-local apheleia--buffer-hash (buffer-hash))
+ (setq-local apheleia--buffer-hash (apheleia--buffer-hash))
(apheleia--run-formatter
command
(lambda (formatted-buffer)
;; Short-circuit.
- (when (equal apheleia--buffer-hash (buffer-hash))
+ (when (equal apheleia--buffer-hash (apheleia--buffer-hash))
(apheleia--create-rcs-patch
(current-buffer) formatted-buffer
(lambda (patch-buffer)
- (when (equal apheleia--buffer-hash (buffer-hash))
+ (when (equal apheleia--buffer-hash (apheleia--buffer-hash))
(apheleia--apply-rcs-patch
(current-buffer) patch-buffer)
(when callback