I don't think there is a built-in mechanism for this, so you may need to roll your own.
Don't have a direct answer, but I have something similar in my config: I don't want to be prompted for confirmation when killing a file that matches what is on disk. To check this I'm running diff and then scanning the output -- you can probably do something similar for your use case.
(defun my/matches-file-p ()
"Return t if the current buffer is identical to its associated file."
(autoload 'diff-no-select "diff")
(when buffer-file-name
(diff-no-select buffer-file-name (current-buffer) nil 'noasync)
(with-current-buffer "*Diff*"
(search-forward-regexp "^Diff finished \(no differences\)\." (point-max) 'noerror))))
(defun my/kill-buffer ()
"Kill the current buffer.
Don't prompt for confirmation if the buffer is unmodified or matches its file."
(interactive)
(when (my/matches-file-p)
(set-buffer-modified-p nil))
(kill-buffer))
Looking more at the auto-revert case. It looks like that prompt comes from after-find-file
, which is looking at timestamps (file-newer-than-file-p
). I don't see a straightforward way to customize or advise this behavior. Maybe you could advise after-find-file
to compare the file with its auto-save file and set the warn
argument to nil if things match.