I want to do something like if the "buffer-changed" but "content-not-changed", reverted the buffer.
When I work on the checking if the content changed, I tested the following code, but it can't work, it always return nil even if I just save the buffer.
(defun file-content-keep-same(BUFFER)
(interactive)
(save-restriction
(widen)
(let ((original-buffer BUFFER)
(original-size (buffer-size BUFFER))
(filename-on-disk (buffer-file-name (current-buffer))))
(message "buffer size %d" original-size)
(with-temp-buffer
(insert-file-contents filename-on-disk)
(message "%s %d" filename-on-disk (point-max))
(zerop
(compare-buffer-substrings original-buffer 1 original-size
(current-buffer) 1 (point-max))))
)
))
where is it wrong for above code?