Subject: bug#21729: doc-view messed up by early auto-revert

From: Stefan Monnier <[email-masked]>
Date: Wed, 21 Oct 2015 14:05:44 -0400

Package: Emacs
Version: 25.0.50

When I work on LaTeX documents, I generally have a doc-view-mode buffer
open displaying the PDF output.  I'd like this document to auto-update
after I recompile the .tex file(s), but using M-x auto-revert-mode
doesn't work well for that:

  emacs -Q foo.pdf
  M-x auto-revert-mode RET

then in a shell

  pdflatex foo

The result is that the doc-view buffer ends up displaying the raw file's
content (for me anyway: it's timing dependent, but I see this
behavior on several machines, with very different performance.  the
foo.tex document needs to be large enough, of course).

I think there are two problems:

- Doc-view should inhibit auto-revert when the file was modified too
  recently (on the assumption that it's not complete yet).

- [ Just guessing here: ] We may sometimes fail to revert the file after
  it's complete, maybe because the last reversion finished after the file
  was complete, even though it started before, so the last reversion
  failed to include some changes that were added while the buffer was
  being reverted.

        Stefan

In GNU Emacs 25.0.50.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bars)
 of 2015-10-16
Repository revision: 26a88b59cd790e9b8ee7656a9c8672079c09ef52
Windowing system distributor 'The X.Org Foundation', version 11.0.11604000
System Description:	Debian GNU/Linux 8.2 (jessie)

Configured using:
 'configure -C --enable-checking --enable-check-lisp-object-type
 'CFLAGS=-Wall -g3 -Og -Wno-pointer-sign'
 PKG_CONFIG_PATH=/home/monnier/lib/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG SOUND NOTIFY GNUTLS LIBXML2 FREETYPE XFT ZLIB
TOOLKIT_SCROLL_BARS LUCID X11

Important settings:
  value of $LANG: C
  locale-coding-system: nil

Major mode: InactiveMinibuffer

Minor modes in effect:
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  electric-pair-mode: t
  url-handler-mode: t
  global-reveal-mode: t
  reveal-mode: t
  auto-insert-mode: t
  savehist-mode: t
  minibuffer-electric-default-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  global-prettify-symbols-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Error during redisplay: (jit-lock-function 12402647) signaled (scan-error "Unbalanced parentheses" 12345873 12345678)
Error during redisplay: (jit-lock-function 12402637) signaled (scan-error "Unbalanced parentheses" 12345793 12345678)
Error during redisplay: (jit-lock-function 12402795) signaled (scan-error "Unbalanced parentheses" 12345781 12345678)
Error during redisplay: (jit-lock-function 12402787) signaled (scan-error "Unbalanced parentheses" 12345701 12345678)
Error during redisplay: (jit-lock-function 12402904) signaled (scan-error "Unbalanced parentheses" 12345688 12345678)
Error during redisplay: (jit-lock-function 12402780) signaled (scan-error "Unbalanced parentheses" 12345830 12345678)
Error during redisplay: (jit-lock-function 12403005) signaled (scan-error "Unbalanced parentheses" 12345753 12345678)
Reverting buffer ‘paper.pdf’.
Type C-c C-c to toggle between editing or viewing the document.
Warning: vc-find-file-hook is obsolete!

Load-path shadows:
/home/monnier/src/emacs/elpa/packages/ada-mode/ada-ref-man hides /home/monnier/src/emacs/elpa/packages/ada-ref-man/ada-ref-man
/home/monnier/src/emacs/elpa/packages/ada-mode/ada-prj hides /home/monnier/src/emacs/work/lisp/progmodes/ada-prj
/home/monnier/src/emacs/elpa/packages/ada-mode/ada-stmt hides /home/monnier/src/emacs/work/lisp/progmodes/ada-stmt
/home/monnier/src/emacs/elpa/packages/ada-mode/ada-mode hides /home/monnier/src/emacs/work/lisp/progmodes/ada-mode
/home/monnier/src/emacs/elpa/packages/ada-mode/ada-xref hides /home/monnier/src/emacs/work/lisp/progmodes/ada-xref
/home/monnier/src/emacs/elpa/packages/crisp/crisp hides /home/monnier/src/emacs/work/lisp/obsolete/crisp
/home/monnier/src/emacs/elpa/packages/landmark/landmark hides /home/monnier/src/emacs/work/lisp/obsolete/landmark
/home/monnier/src/emacs/work/lisp/emacs-lisp/cl-generic hides /home/monnier/src/emacs/elpa/packages/cl-generic/cl-generic

Features:
(mail-extr emacsbug message rfc822 mml mml-sec mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev mailheader sendmail rfc2047
rfc2045 ietf-drums mail-utils eieio-opt speedbar sb-image ezimage dframe
add-log log-view pcvs-util dabbrev autorevert filenotify doc-view
jka-compr image-mode dired format-spec reftex-sel cursor-sensor
reftex-ref reftex-parse reftex-toc reftex-dcr reftex reftex-vars
tex-mode compile shell pcomplete latexenc executable copyright xscheme
warnings unsafep trace testcover shadow scheme re-builder profiler
inf-lisp ielm pp comint ansi-color ring gmm-utils ert find-func ewoc
debug elp edebug cl-indent cus-edit cus-start cus-load wid-edit sort mpc
misearch multi-isearch vc vc-dispatcher vc-git diff-mode filecache
epa-file epa derived epg server noutline outline easy-mmode flyspell
ispell checkdoc thingatpt load-dir elec-pair url-handlers url-parse
auth-source eieio byte-opt bytecomp byte-compile cl-extra cconv
gnus-util time-date mm-util help-fns help-mode mail-prsvr password-cache
url-vars reveal autoinsert proof-site proof-autoloads cl pg-vars
savehist minibuf-eldef finder-inf advice info eieio-core cl-macs gv
cl-loaddefs pcase cl-lib package easymenu epg-config bbdb-autoloads
vm-autoloads disp-table mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax font-core frame
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote inotify dynamic-setting
font-render-setting x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 273500 37468)
 (symbols 48 29159 0) (miscs 40 3792 1044) (strings 32 64808 12475)
 (string-bytes 1 2487240)
 (vectors 16 40418) (vector-slots 8 1637632 116578) (floats 8 425 624)
 (intervals 56 13968 376)
 (buffers 976 35) (heap 1024 392922 6279))