jsinglet / latex-preview-pane

Makes LaTeX editing less painful by providing a updatable preview pane
130 stars 24 forks source link

Render issues with Emacs 25 #37

Open mneilly opened 7 years ago

mneilly commented 7 years ago

I'm seeing incorrectly rendered pdfs when using latex-preview-pane-mode with Emacs 25.3.1 on Mac OS X 10.13 and with Emacs 25.1.1 on Debian 9. The same issue does not occur with Emacs 24.5.1 on Debian 9.

Creating a new latex file and writing it out results in a PDFView buffer which is correctly rendered.

image

If I subsequently change the latex file and write it out the PDFView is not updated. Clicking in the PDF buffer or resizing emacs results in an update but the rendered PDF is incorrect.

image

Viewing the updated PDF with preview shows the issue is not with the PDF file itself. And viewing the same PDF with a python script using the same poppler library shows the correct result as well.

It looks like the definition of doc-view-revert-buffer changed in Emacs 25.

Emacs 24.5.1 doc-view-revert-buffer:

(defun doc-view-revert-buffer (&optional ignore-auto noconfirm)
  "Like `revert-buffer', but preserves the buffer's current modes."
  ;; FIXME: this should probably be moved to files.el and used for
  ;; most/all "g" bindings to revert-buffer.
  (interactive (list (not current-prefix-arg)))
  (revert-buffer ignore-auto noconfirm 'preserve-modes))

Emacs 25.1 doc-view-revert-buffer:

(defun doc-view-revert-buffer (&optional ignore-auto noconfirm)
  "Like `revert-buffer', but preserves the buffer's current modes."
  (interactive (list (not current-prefix-arg)))
  (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))))

If I modify latex-preview-pane-update-p() as follows the PDFView is updated as expected:

              ;(doc-view-revert-buffer nil t)                                                                                                                          
              (revert-buffer nil t 'preserve-modes)
jsinglet commented 7 years ago

Would you mind putting this together in a PR?