Function: revert-buffer-insert-file-contents--default-function
revert-buffer-insert-file-contents--default-function is a
byte-compiled function defined in files.el.gz.
Signature
(revert-buffer-insert-file-contents--default-function FILE-NAME AUTO-SAVE-P)
Documentation
Default function for revert-buffer-insert-file-contents-function.
The function revert-buffer--default calls this.
FILE-NAME is the name of the file. AUTO-SAVE-P is non-nil if this is
an auto-save file.
Source Code
;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun revert-buffer-insert-file-contents--default-function (file-name auto-save-p)
"Default function for `revert-buffer-insert-file-contents-function'.
The function `revert-buffer--default' calls this.
FILE-NAME is the name of the file. AUTO-SAVE-P is non-nil if this is
an auto-save file."
(cond
((not (file-exists-p file-name))
(error (if buffer-file-number
"File %s no longer exists!"
"Cannot revert nonexistent file %s")
file-name))
((not (file-readable-p file-name))
(error (if buffer-file-number
"File %s no longer readable!"
"Cannot revert unreadable file %s")
file-name))
(t
(widen)
(let ((coding-system-for-read
;; Auto-saved file should be read by Emacs's
;; internal coding.
(if auto-save-p 'auto-save-coding
(or coding-system-for-read
(and
buffer-file-coding-system-explicit
(car buffer-file-coding-system-explicit))))))
(if (and (not enable-multibyte-characters)
coding-system-for-read
(not (memq (coding-system-base
coding-system-for-read)
'(no-conversion raw-text))))
;; As a coding system suitable for multibyte
;; buffer is specified, make the current
;; buffer multibyte.
(set-buffer-multibyte t))
;; This force after-insert-file-set-coding
;; (called from insert-file-contents) to set
;; buffer-file-coding-system to a proper value.
(kill-local-variable 'buffer-file-coding-system)
;; Note that this preserves point in an intelligent way.
(if revert-buffer-preserve-modes
(let ((buffer-file-format buffer-file-format))
(insert-file-contents file-name (not auto-save-p)
nil nil 'if-regular))
(insert-file-contents file-name (not auto-save-p)
nil nil 'if-regular))))))