masm11 / emacs

Mirror of GNU Emacs
http://www.gnu.org/software/emacs/
GNU General Public License v3.0
198 stars 14 forks source link

pdf-tools sync issue, arrow does not render #38

Closed A6GibKm closed 4 years ago

A6GibKm commented 4 years ago

When pressing C-c C-v (TeX-view) with

(setq TeX-source-correlate-mode t
      TeX-source-correlate-method 'synctex)

enabled, the expected behaviour is that emacs shows a red arrow with white background on the pdf, correlating the source and pdf. On pgtk I get a grey background only.

image

A6GibKm commented 4 years ago

I think the actual function to look into might be TeX-pdf-tools-sync-view defined in auctex/tex.el.

A6GibKm commented 4 years ago

I get the impression that the location shown on the pdf is also slightly wrong. I am sorry but I am unable to test vanilla emacs 27 right now.

Tested on vanilla emacs. The behaviour is the same minus the fact that the arrow itself does not render.

masm11 commented 4 years ago

Can you tell me how to reproduce?

On X build, I wrote this in ~/.emacs:

(setq TeX-source-correlate-mode t
      TeX-source-correlate-method 'synctex)

and open a pdf file and press C-c C-v, but C-c C-v is undefined.

A6GibKm commented 4 years ago

Ok, will do but I can't right now. It is going to take a bit to decouple my config from doom emacs.

A6GibKm commented 4 years ago

Does this init file works for you?

;;; ~/.emacs -*- lexical-binding: t; -*-

(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(eval-when-compile
  (require 'use-package))

(use-package pdf-tools
  :ensure t
  :magic ("%PDF" . pdf-view-mode)
  :commands (pdf-tools-install TeX-revert-document-buffer)
  :hook (after-init . pdf-loader-install))

(use-package latex
  :ensure auctex
  :mode ("\\.tex\\'" . LaTeX-mode)
  :config
  (setq TeX-PDF-mode t
        TeX-auto-save t
        TeX-parse-self t
        TeX-save-query nil
        TeX-master t
        TeX-view-program-selection '((output-pdf "PDF Tools"))
        TeX-source-correlate-start-server t
        TeX-source-correlate-mode t))

I haven't ever configured both pdf-tools and latex mode without use-package. I can reproduce it with only this snippet on a .tex file.

masm11 commented 4 years ago

Thanks. Two more questions:

I'll try tomorrow night.

A6GibKm commented 4 years ago

I don't have tex environment. Do I need to install it to reproduce your issue?

Not really, but you need a precompiled tex and pdf foo.{tex,pdf} files with the respective foo.synctex.gz file (as far as I know).

Can empty tex file reproduce your issue?

An almost empty file should suffice.

I uploaded here https://www.dropbox.com/s/wj8msslg7642yg3/test%20tex.tar.xz?dl=0 a test file with 'Lorem Ipsum' that is able to reproduce the error when the cursor is over a character of Lorem. Tested on a clean Fedora 32 toolbox enviroment which only has dnf install @development-tools emacs jansson (without tex) and the requirements for pdf-tools, plus the config above.

I am sorry to use non-free dropbox but firefox send is not available now and I could not think of another mechanism.

masm11 commented 4 years ago

Thank you. Reproduced. After pressing C-c C-v, background colored rectangle appears for a few seconds.

only-bg

masm11 commented 4 years ago

X-emacs can switch how to handle tooltips. When x-gtk-use-system-tooltips is t, tooltips are handled by Gtk. When nil, by X. X tooltips can do almost anything, but Gtk tooltips can't do all of them.

I didn't implement x-gtk-use-system-tooltips on pgtk emacs, because I thought the code for x-gtk-use-system-tooltips of nil should be obsoleted.

The red arrow by pdf-tools is a tooltip with x-gtk-use-system-tooltips of nil, so can't be displayed. The background-colored rectangle is an empty Gtk tooltip.

I'll try to reimplement the code with Gtk, but don't expect.

A6GibKm commented 4 years ago

Fair enough. In any case, it is an interesting point to have in mind for a future rebase onto Emacs' codebase. On the other hand it turns out the maintainer of pdf-tools is MIA since may for all I know, which makes this more involved.

masm11 commented 4 years ago

I implemented non-system tooltip. It is working on:

Could you try #42?

A6GibKm commented 4 years ago

The initial issue is fixed in #42 for GNOME (Wayland).

The arrow does not render in the same size as in vanilla emacs. Although it could be an issue related to the original X implementation being emulated in Xwayland, and I have no way of telling how this features was originally designed.

I consider this fixed.