AW <[email protected]> writes:

> (require 'subr-x)
> (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)

Note that this private function of mine is now included in AUCTeX in a
slightly different version that works for doc-view and pdf-tools.  The
manual describes the setup.

,----[ (info "(auctex)Modes and Hooks") ]
|  -- Variable: TeX-after-TeX-LaTeX-command-finished-hook
|      Hook which is run after the TeX/LaTeX processor has successfully
|      finished compiling your document.  (*Note Processing::, for finding
|      out how to compile your document).  Each function in the hook is
|      run with the compiled output document as its argument.
| 
|      This is useful for automatically refreshing the viewer after
|      re-compilation especially when using Emacs viewers such as DocView
|      or PDF Tools.  The function 'TeX-revert-document-buffer' can be
|      added to the hook for this purpose.
`----

,----[ C-h f TeX-revert-document-buffer RET ]
| TeX-revert-document-buffer is a compiled Lisp function in ‘tex-buf.el’.
| 
| (TeX-revert-document-buffer FILE)
| 
| Revert the buffer visiting FILE.
| This function is intended to be used in
| ‘TeX-after-TeX-LaTeX-command-finished-hook’ for users that view
| their compiled document with an emacs viewer such as
| ‘doc-view-mode’ or ‘pdf-view-mode’.  (Note that this function
| just calls ‘revert-buffer’ in the respective buffer and thus
| requires that the corresponding mode defines a sensible
| ‘revert-buffer-function’.)
`----

Bye,
Tassilo


_______________________________________________
auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex

Reply via email to