Function: userlock--check-content-unchanged
userlock--check-content-unchanged is a byte-compiled function defined
in userlock.el.gz.
Signature
(userlock--check-content-unchanged FILENAME)
Source Code
;; Defined in /usr/src/emacs/lisp/userlock.el.gz
(defun userlock--check-content-unchanged (filename)
(with-demoted-errors "Unchanged content check: %S"
;; Even tho we receive `filename', we know that `filename' refers to the current
;; buffer's file.
(cl-assert (equal (expand-file-name filename)
(expand-file-name buffer-file-truename)))
;; Note: rather than read the file and compare to the buffer, we could save
;; the buffer and compare to the file, but for encrypted data this
;; wouldn't work well (and would risk exposing the data).
(save-restriction
(widen)
(let ((buf (current-buffer))
(cs buffer-file-coding-system)
(start (point-min))
(end (point-max)))
;; FIXME: To avoid a slow `insert-file-contents' on large or
;; remote files, it'd be good to include file size in the
;; "visited-modtime" check.
(when (with-temp-buffer
(let ((coding-system-for-read cs)
(non-essential t))
(insert-file-contents filename))
(when (= (buffer-size) (- end start)) ;Minor optimization.
(= 0 (let ((case-fold-search nil))
(compare-buffer-substrings
buf start end
(current-buffer) (point-min) (point-max))))))
(set-visited-file-modtime)
'unchanged)))))