mirror of
https://github.com/vale981/apheleia
synced 2025-03-05 17:41:41 -05:00
Backwards compatibility for (buffer-hash)
This commit is contained in:
parent
ef86b0c4a3
commit
55ee664caa
1 changed files with 9 additions and 3 deletions
12
apheleia.el
12
apheleia.el
|
@ -494,6 +494,12 @@ even if a formatter is configured."
|
||||||
(user-error "No configuration for formatter `%S'"
|
(user-error "No configuration for formatter `%S'"
|
||||||
formatter))))
|
formatter))))
|
||||||
|
|
||||||
|
(defun apheleia--buffer-hash ()
|
||||||
|
"Compute hash of current buffer."
|
||||||
|
(if (fboundp 'buffer-hash)
|
||||||
|
(buffer-hash)
|
||||||
|
(md5 (current-buffer))))
|
||||||
|
|
||||||
(defvar apheleia--buffer-hash nil
|
(defvar apheleia--buffer-hash nil
|
||||||
"Return value of `buffer-hash' when formatter started running.")
|
"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
|
(if current-prefix-arg
|
||||||
'prompt
|
'prompt
|
||||||
'interactive))))
|
'interactive))))
|
||||||
(setq-local apheleia--buffer-hash (buffer-hash))
|
(setq-local apheleia--buffer-hash (apheleia--buffer-hash))
|
||||||
(apheleia--run-formatter
|
(apheleia--run-formatter
|
||||||
command
|
command
|
||||||
(lambda (formatted-buffer)
|
(lambda (formatted-buffer)
|
||||||
;; Short-circuit.
|
;; Short-circuit.
|
||||||
(when (equal apheleia--buffer-hash (buffer-hash))
|
(when (equal apheleia--buffer-hash (apheleia--buffer-hash))
|
||||||
(apheleia--create-rcs-patch
|
(apheleia--create-rcs-patch
|
||||||
(current-buffer) formatted-buffer
|
(current-buffer) formatted-buffer
|
||||||
(lambda (patch-buffer)
|
(lambda (patch-buffer)
|
||||||
(when (equal apheleia--buffer-hash (buffer-hash))
|
(when (equal apheleia--buffer-hash (apheleia--buffer-hash))
|
||||||
(apheleia--apply-rcs-patch
|
(apheleia--apply-rcs-patch
|
||||||
(current-buffer) patch-buffer)
|
(current-buffer) patch-buffer)
|
||||||
(when callback
|
(when callback
|
||||||
|
|
Loading…
Add table
Reference in a new issue