From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.bugs Subject: bug#21729: doc-view messed up by early auto-revert Date: Thu, 22 Oct 2015 08:22:05 +0200 Message-ID: <874mhjtoc2.fsf@gnu.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1445495007 13061 80.91.229.3 (22 Oct 2015 06:23:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Oct 2015 06:23:27 +0000 (UTC) Cc: 21729@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 22 08:23:14 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zp9HM-0000iJ-HV for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 Oct 2015 08:23:12 +0200 Original-Received: from localhost ([::1]:56698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zp9HM-0005FU-0d for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 Oct 2015 02:23:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zp9HH-0005Em-Ad for bug-gnu-emacs@gnu.org; Thu, 22 Oct 2015 02:23:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zp9HC-00054D-9Z for bug-gnu-emacs@gnu.org; Thu, 22 Oct 2015 02:23:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41225) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zp9HC-00053o-6U for bug-gnu-emacs@gnu.org; Thu, 22 Oct 2015 02:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Zp9HB-00028Y-Sf for bug-gnu-emacs@gnu.org; Thu, 22 Oct 2015 02:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tassilo Horn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 22 Oct 2015 06:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21729 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21729-submit@debbugs.gnu.org id=B21729.14454949308144 (code B ref 21729); Thu, 22 Oct 2015 06:23:01 +0000 Original-Received: (at 21729) by debbugs.gnu.org; 22 Oct 2015 06:22:10 +0000 Original-Received: from localhost ([127.0.0.1]:60166 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zp9GM-00027H-06 for submit@debbugs.gnu.org; Thu, 22 Oct 2015 02:22:10 -0400 Original-Received: from nsmtp.uni-koblenz.de ([141.26.64.14]:43546) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zp9GI-000278-E8 for 21729@debbugs.gnu.org; Thu, 22 Oct 2015 02:22:08 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by nsmtp.uni-koblenz.de (Postfix) with ESMTP id 7B9F823ADBF; Thu, 22 Oct 2015 08:22:05 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at uni-koblenz.de Original-Received: from nsmtp.uni-koblenz.de ([127.0.0.1]) by localhost (nsmtp.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PC8ExslSr9xU; Thu, 22 Oct 2015 08:22:05 +0200 (CEST) Original-Received: from deliver.uni-koblenz.de (deliver.uni-koblenz.de [141.26.64.15]) by nsmtp.uni-koblenz.de (Postfix) with ESMTPS; Thu, 22 Oct 2015 08:22:05 +0200 (CEST) Original-Received: from thinkpad-t440p (dhcp66.uni-koblenz.de [141.26.71.66]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id 7540D1A830F; Thu, 22 Oct 2015 08:22:05 +0200 (CEST) In-Reply-To: (Stefan Monnier's message of "Wed, 21 Oct 2015 14:05:44 -0400") User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:107829 Archived-At: Stefan Monnier writes: Hi Stefan, > 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). Yes, I experienced the same problem although with the PDF Tools viewer when I tried to enable `auto-revert-mode' in the PDF file buffer. What I do now instead is --8<---------------cut here---------------start------------->8--- (defun th/pdf-view-revert-buffer-maybe (file) (when-let ((buf (find-buffer-visiting file))) (with-current-buffer buf (when (derived-mode-p 'pdf-view-mode) (pdf-view-revert-buffer nil t))))) (add-hook 'TeX-after-TeX-LaTeX-command-finished-hook #'th/pdf-view-revert-buffer-maybe) --8<---------------cut here---------------end--------------->8--- i.e., I revert the buffer from an AUCTeX hook that's run after the compilation has finished. > 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). Something like checking if the file's MTIME is more than a second ago? Hm, no, that won't work. I currently work on some large document (~450 pages). When I compile that, the file changes several times per second during the compilation, then it doesn't change for ~15 seconds while latex (lualatex in this case) is still running, and then starts changing again for maybe 3 seconds. I think the long delay is caused by computing the index and bibliography. I just checked that during that period, actually no file changes, e.g., neither pdf, aux, bcf, idx, etc. The only thing I can see is that there's a foo.synctex.gz(busy) file which really disappears when the compilation has finished but of course nobody is required to use synctex. Well, one reasonably reliable way to test if a pdf file is correct is calling pdfinfo (provided by poppler) on it. A non-zero exit status indicated that the file is broken/incomplete. Should we use that? > - [ 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. Yeah, that's possible. And I think there could also be a problem when people use latexmk which compiles your document several times until all refs are defined and its stable. Here, we might revert exactly between two latex runs. Bye, Tassilo