When exporting an org document to pdf via LaTeX, C-c C-e l o
, if the pdf to be generated has already been visited in an existing buffer, neither of the variables auto-revert-mode
nor global-auto-revert-mode
are respected.
During the export process, org-export-dispatch
calls org-open-file
which in turn calls find-file-other-window
, which in turn causes part of the problem by calling find-file-noselect
with its nowarn argument set to nil.
I'm not sure of the best way to go about this, but I believe the solution would be to modify the yes-or-no-p
statement, lines 2040 - 2055 of .../emacs/26.0.50/lisp/files.el.gz:
...
((yes-or-no-p
(if (string= (file-name-nondirectory filename)
(buffer-name buf))
(format
(if (buffer-modified-p buf)
"File %s changed on disk. Discard your edits? "
"File %s changed on disk. Reread from disk? ")
(file-name-nondirectory filename))
(format
(if (buffer-modified-p buf)
"File %s changed on disk. Discard your edits in %s? "
"File %s changed on disk. Reread from disk into %s? ")
(file-name-nondirectory filename)
(buffer-name buf))))
(with-current-buffer buf
(revert-buffer t t)))))
...
such that when the buffer is not modified and (global-)auto-revert-mode
is set, then automatically return yes
without prompt.
Not sure if this should be filed as a bug?
When I compile the corresponding tex file that is generated as part of the org-export
process, (global-)auto-revert-mode
is respected, and the pdf buffer is automatically reverted.
Edit
This issue does not manifest itself when I start a standalone Emacs session, and manually open the compiled pdf with C-x C-f
.
It does however, when I am working within a daemon, through emacsclient -c -a ""
. Emacsclient is my default application for opening pdfs. I.e. in my init file, I have (setq org-file-apps '(("\\.pdf\\'" . "emacsclient \"%s\"")))