+ (cl-labels ((revert ()
+ (let (revert-buffer-function)
+ (revert-buffer ignore-auto noconfirm 'preserve-modes))))
+ (if (and (eq 'pdf doc-view-doc-type)
+ (executable-find "pdfinfo"))
+ ;; We don't want to revert if the PDF file is corrupted which
+ ;; might happen when it it currently recompiled from a tex
+ ;; file. (TODO: We'd like to have something like that also
+ ;; for other types, at least PS, but I don't know a good way
+ ;; to test if a PS file is complete.)
+ (if (= 0 (call-process (executable-find "pdfinfo") nil nil nil
+ doc-view--buffer-file-name))
+ (revert)
+ (when (called-interactively-p 'interactive)
+ (message "Can't revert right now because the file is corrupted.")))
+ (revert))))